Fetch data to CDS via a NRQL query.
The component can return data in a format compatible with the Chart component.
Usage
import { NrqlQuery } from 'nr1'
Examples
Transform data
<NrqlQuery accountIds={[1]} query="SELECT count(*) FROM `Synthetics` SINCE 1 DAY AGO TIMESERIES AUTO FACET jobType"> {({ data }) => { if (data) { // change colors to a nice pink. data.forEach(({ metadata }) => (metadata.color = '#F00BA5')); }
return <LineChart data={data} />; }}</NrqlQuery>
Polling data
<NrqlQuery pollInterval={2000} accountIds={[1]} query="SELECT count(*) FROM `Synthetics` SINCE 1 DAY AGO TIMESERIES AUTO FACET jobType"> {({ data }) => { return <LineChart data={data} />; }}</NrqlQuery>
Auto polling
<NrqlQuery pollInterval={NrqlQuery.AUTO_POLL_INTERVAL} accountIds={[1]} query="SELECT count(*) FROM `Synthetics` SINCE 1 DAY AGO TIMESERIES AUTO FACET jobType"> {({ data }) => { return <LineChart data={data} />; }}</NrqlQuery>
Props
DEPRECATEDnumber | Due November 1st, 2022The "accountId" prop is deprecated, use "accountIds" prop instead. Identifier of the account to execute the NRQL query against. |
REQUIREDnumber[] | Identifiers of accounts to execute the NRQL query against. |
function | Render prop function as a child. function ( |
enum | Format of the response. <One of |
number | Offset to apply to the computed begin_time and end_time, in epoch milliseconds. This offset is only applied when the query is open ended, that is:1. end_time is not specified, and 2. duration is specified.If these conditions are met and an offset value is present, the effective end_time will be set to offset milliseconds ending now, while the effective begin_time will be set to (offset + duration) milliseconds before that end_time. |
number|enum | Interval in millisecond to poll for new data or automatically set based on response data's metadata. |
REQUIREDstring | NRQL query. See NRQL documentation for reference. |
boolean | When set to |
shape | Time range to scope NRQL query time range. When only duration is provided it uses duration to query from NOW back until DURATION (aka Open ended query). When begin_time and end_time are provided it uses them to query SINCE begin_time UNTIL end_time (aka Closed query). shape
number
number
number |
Methods
NrqlQuery.query
function (props: Object Object containing the query options. Any NrqlQuery
prop is a valid option except children
and pollInterval
.
) => PromiseQueryResult
Type definitions
PromiseQueryResult
{error: ApolloClient.ApolloError, Runtime error with graphQLErrors
and networkError
properties.
data: Object, Object containing the result of your query.
fetchMore: function|null, If not null
, fetchMore
allows you to load more results for your query. New data is merged with previous data.
refetch: function, Refetch the query.
}
QueryResult
{loading: boolean, Indicates that the request is in flight.
error: ApolloClient.ApolloError, Runtime error with graphQLErrors
and networkError
properties.
data: Object, Object containing the result of your query.
fetchMore: function|null, If not null
, fetchMore
allows you to load more results for your query. New data is merged with previous data.
refetch: function, Refetch the query.
}