• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

NrqlQuery

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

accountId

DEPRECATED
number

Due November 1st, 2022

The "accountId" prop is deprecated, use "accountIds" prop instead.

Identifier of the account to execute the NRQL query against.

accountIds

REQUIRED
number[]

Identifiers of accounts to execute the NRQL query against.

children

function

Render prop function as a child.

function (
queryResult: QueryResult

Results of the query.

) => React.ReactNode

formatType

enum

Format of the response.

<One of

NrqlQuery.FORMAT_TYPE.CHART, NrqlQuery.FORMAT_TYPE.RAW,

>

offset

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.

pollInterval

number|enum

Interval in millisecond to poll for new data or automatically set based on response data's metadata.

query

REQUIRED
string

NRQL query. See NRQL documentation for reference.

skip

boolean

When set to true, the query will be skipped entirely from rendering.

timeRange

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

begin_time

number

duration

number

end_time

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.

}
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.