Entities & relationships examples via NRQL (E&R via NRQL)
Streamline your system analysis by using New Relic Query Language (NRQL) to directly query entity and relationship data. This approach replaces cumbersome manual processes for crucial tasks like correlating CPU performance with host attributes, viewing past entity states, or tracking configuration changes, offering faster insights into your complex environments.
To query this data, you'll need Advanced Compute; use the Entity event type (and Relationships or entityRelationships for relationship-specific queries).
Explore the practical NRQL solutions below to help you:
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:
FROM SystemSample
JOIN(FROM Entity SELECT id, name WHEREtype='INFRA-HOST'AND`tags.aws.awsRegion`='eu-central-1')
ON entityGuid = id
SELECT average(cpuPercent) FACET name
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.
FROM Entity
SELECT*
WHERE id ='<your_entity_id>'
SINCE 7 hours ago UNTIL 6 hours ago
LIMIT1
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.
SELECT*
FROM Entity
WHERE id ='<your_entity_id>'
SINCE 3 hours ago
Objective: Identify the applications running on specific hosts
Challenge: Difficult to correlate applications to hosts