Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added the nrql query
  • Loading branch information
adutta-newrelic committed May 15, 2025
commit 4c9d1f925ac78d1cc05352f1212a8db2890130d1
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: 'Querying entities & relationships via NRQL'
metaDescription: 'New Relic Advanced Compute customers leverage NRQL to directly query entity and relationship data within NRDB. This capability simplifies the correlation of this data with telemetry, leading to faster insights and a more comprehensive understanding of systems.'
freshnessValidatedDate: 2024-03-19
---

Advanced Compute customers query entities and their relationships directly from New Relic Database (NRDB) using the New Relic Query Language (NRQL). This feature enables the seamless joining of entity and relationship data with telemetry data within a unified platform.

### Overcoming data fragmentation

Previously, entity, relationship, and telemetry data were often distributed across different data stores. This fragmentation posed several challenges:

- Performing even basic queries could be cumbersome.
- Correlating system entities and their relationships with performance metrics required complex joins.
- The time and effort needed to gain comprehensive insights were significantly increased.

### Unified data access with NRQL

This feature centralizes data by making entities and their relationships available within NRDB. The functionality includes:

- **Unified datastore**: Entity and relationship data is ingested and stored in NRDB.
- **24-hour availability**: This data is retained in NRDB for a 24-hour period, enabling timely analysis and correlation.
- **NRQL queries**: Users query this data using the power and flexibility of NRQL.
- **Simplified correlation**: Entities, their relationships, and associated telemetry data are easily correlated to provide a complete picture of the environment.

## Key benefits

Integrating entity and relationship querying into NRQL offers several key advantages:

- **Simplified queries**: NRQL is used directly to query entities and relationships. This eliminates the need for complex joins across disparate data stores, making queries more straightforward and easier to manage.
- **Unified data platform**: All relevant data—entities, relationships, and telemetry—is accessible within a single, cohesive platform.
- **Faster insights**: Information needed to understand system behavior, identify dependencies, and troubleshoot issues is retrieved quickly and efficiently.
- **Improved correlation**: Entities and their relationships are effortlessly linked with telemetry data (like metrics, events, logs, and traces) to provide a holistic view of an environment's health and performance.

## Use cases

The following use cases illustrate how this feature transforms common observability tasks:

- Correlating CPU usage with Host attributes

- **Objective**: An operations team needs to analyze CPU utilization for all production hosts located in a specific AWS region (e.g., 'eu-central-1') to identify potential performance bottlenecks.
- **Challenge**: This often required exporting host data and performance metrics separately and then using external tools or complex scripts to join and analyze them.
- **NRQL solution**:

```sql
FROM SystemSample
JOIN (FROM Entity SELECT id, name WHERE type = 'INFRA-HOST' AND `tags.aws.awsRegion` = 'eu-central-1')
ON entityGuid = id
SELECT average(cpuPercent) FACET name
```

- Viewing Entity state at a specific point in time

- **Objective**: A developer is investigating an incident that occurred several hours ago and needs to know the exact configuration or state of a specific host (or container, application, etc.) at that particular point in time.

- **Challenge**: Obtaining a snapshot of an entity's attributes from a specific past timeframe was often not possible or required sifting through voluminous configuration logs, if available.

- **NRQL solution**: This query retrieves all available attributes for a specific entity (identified by its id) within a narrow one-hour window from seven hours ago.

```sql
FROM Entity
SELECT *
WHERE id = '<your_entity_id>'
SINCE 7 hours ago UNTIL 6 hours ago
LIMIT 1
```

- Tracking entity state changes

- **Objective**: An SRE wants to understand how an entity's configuration or key attributes have changed over the last few hours, perhaps to see if a deployment or an automated process has altered its state as expected.

- **Challenge**: Tracking subtle changes in an entity's state over time was difficult and often involved manual comparisons or custom monitoring scripts.

- **NRQL solution**: This query fetches all recorded states for a particular entity within the last three hours, allowing for an audit of any changes.

```sql
SELECT *
FROM Entity
WHERE id = '<your_entity_id>'
SINCE 3 hours ago
```

## How to access Entities & Relationships

This feature is available to New Relic customers on Advanced Compute. These customers can begin querying entity and relationship data using the Entity event type

```sql
FROM Relationships o FROM entityRelationships
```
2 changes: 2 additions & 0 deletions src/nav/nrql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pages:
path: /docs/nrql/using-nrql/arrays-in-nrql
- title: Buckets
path: /docs/nrql/using-nrql/nrql-segment-your-data-buckets
- title: Querying via NRQL
path: /docs/nrql/using-nrql/query-entities-and-relationships-via-nrql
- title: Dimensional metrics
path: /docs/nrql/using-nrql/query-infrastructure-dimensional-metrics-nrql
- title: Facet results by time
Expand Down
Loading