Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 770 Bytes

File metadata and controls

30 lines (24 loc) · 770 Bytes

timeRangeToNrql

The timeRangeToNrql utility converts the timeRange provided by the New Relic platform into a NRQL compliant time clause.

For instance, a timeRange structured like this:

{
    "timeRange": {
        "begin_time": null,
        "duration": 1800000,
        "end_time": null
    }
}

will return a NRQL clause of SINCE 30 MINUTES AGO

example

import React, { useContext } from 'react';
import { PlatformStateContext } from 'nr1';
import { timeRangeToNrql } from '@newrelic/nr-labs-components';

const myNerdlet = () => {
  const platformState = useContext(PlatformStateContext)
  return (<pre>timeRangeToNrql(platformState)</pre>)
}
export default myNerdlet