This guide provides ready-to-use NRQL queries for common security monitoring and analysis scenarios. Copy these queries into the query builder or add them to custom dashboards to gain deeper insights into your vulnerability data.
For information about the underlying data structure, see Security data structure reference.
Important
These queries are written against the real Vulnerability event schema. Note the following schema limitations:
- The
Vulnerabilityevent has nostateor lifecycle field — queries cannot filter by OPEN/CLOSED status. - There is no
resolvedAtfield — MTTR and remediation velocity queries that require a resolved timestamp cannot be reproduced from this event. cvss.scoreandepss.percentileare stored as strings. Usenumeric()to cast them before comparing or aggregating numerically.ORDER BY numeric(...)is not supported. Alias the cast inSELECTand useLIMITto retrieve top results.HAVINGon faceted aggregates is not supported. UseLIMITto return top-N results instead.
Executive reporting
Total open vulnerabilities by severity
Get a high-level view of your vulnerability exposure:
FROM VulnerabilitySELECT count(*) AS 'Total Vulnerabilities'FACET severitySINCE 7 days agoCritical and high severity trends
Track how critical vulnerabilities change over time:
FROM VulnerabilitySELECT count(*) AS 'Critical & High Vulnerabilities'WHERE severity IN ('CRITICAL', 'HIGH')TIMESERIES AUTOSINCE 7 days agoVulnerabilities by entity
Identify which applications or hosts have the most vulnerabilities:
FROM VulnerabilitySELECT count(*) AS 'Vulnerability Count'FACET entityLookupValueLIMIT 20SINCE 7 days agoVulnerability distribution across portfolio
Understand the spread of vulnerabilities:
FROM VulnerabilitySELECT percentage(count(*), WHERE severity = 'CRITICAL') AS 'Critical %', percentage(count(*), WHERE severity = 'HIGH') AS 'High %', percentage(count(*), WHERE severity = 'MEDIUM') AS 'Medium %', percentage(count(*), WHERE severity = 'LOW') AS 'Low %'SINCE 7 days agoPrioritization and risk assessment
High-priority vulnerabilities
Find vulnerabilities with high exploit probability:
FROM VulnerabilitySELECT cve, package, package.version, numeric(cvss.score) AS 'cvssScore', numeric(epss.percentile) AS 'epssPercentile'WHERE numeric(epss.percentile) > 0.9SINCE 30 days agoLIMIT 20High-exploitability vulnerabilities
Identify vulnerabilities with a known exploit:
FROM VulnerabilitySELECT count(*) AS 'Findings', max(numeric(cvss.score)) AS 'Max CVSS'WHERE exploitKnown = 'true'FACET cve, entityLookupValue, packageSINCE 30 days agoTip
The Vulnerability event does not have an activeRansomware field. This query uses exploitKnown as the closest available indicator for high-risk findings. If this query returns no results, no findings with a confirmed known exploit have been ingested yet — the query is schema-valid and will return data once such findings appear.
Newly detected critical vulnerabilities
Monitor for new critical findings:
FROM VulnerabilitySELECT cve, package, package.version, entityLookupValue, firstDetectedWHERE severity = 'CRITICAL'SINCE 30 days agoVulnerabilities requiring immediate attention
Combine multiple risk factors:
FROM VulnerabilitySELECT count(*) AS 'Findings', max(numeric(cvss.score)) AS 'Max CVSS', max(numeric(epss.percentile)) AS 'Max EPSS'WHERE (severity = 'CRITICAL' AND numeric(epss.percentile) > 0.85) OR exploitKnown = 'true' OR numeric(epss.percentile) > 0.95FACET cve, entityLookupValue, packageSINCE 30 days agoExposure and remediation tracking
Caution
The Vulnerability event does not include a resolvedAt field or a state (OPEN/CLOSED) lifecycle field. Queries for mean time to remediate (MTTR), remediation velocity, and critical vulnerability response time cannot be computed from this event as currently ingested. To track remediation metrics, use a separate data source such as issue or ticket-tracking data.
Longest-running open vulnerabilities
Find vulnerabilities that have been detected for extended periods:
FROM VulnerabilitySELECT min(firstDetected) AS 'First Detected', count(*) AS 'Occurrences'FACET cve, entityLookupValue, packageLIMIT 20SINCE 90 days agoVulnerabilities by age bucket
Group vulnerabilities by detection period:
FROM VulnerabilitySELECT count(*) AS 'Vulnerabilities'TIMESERIES 1 weekSINCE 180 days agoPackage and library analysis
Most vulnerable libraries
Identify libraries introducing the most vulnerabilities:
FROM VulnerabilitySELECT count(*) AS 'Vulnerability Count'FACET packageLIMIT 10SINCE 7 days agoLibraries requiring upgrades
Find packages with available fixes:
FROM VulnerabilitySELECT count(*) AS 'Vulnerable Entities'WHERE remediation.exists = 'true'FACET package, package.versionLIMIT 20SINCE 7 days agoVulnerability detection by source
Understand which integrations are finding vulnerabilities:
FROM VulnerabilitySELECT count(*) AS 'Detections'FACET sourceSINCE 30 days agoJava dependencies analysis
Focus on Java-specific vulnerabilities:
FROM VulnerabilitySELECT count(*) AS 'Vulnerabilities'WHERE package LIKE '%.jar' OR package LIKE '%maven%' OR package.language = 'java'FACET package, severitySINCE 30 days agoLIMIT 20Entity-specific queries
Application vulnerability summary
Get vulnerability counts for a specific application:
FROM VulnerabilitySELECT count(*) AS 'Total', filter(count(*), WHERE severity = 'CRITICAL') AS 'Critical', filter(count(*), WHERE severity = 'HIGH') AS 'High', filter(count(*), WHERE severity = 'MEDIUM') AS 'Medium', filter(count(*), WHERE severity = 'LOW') AS 'Low'WHERE entityLookupValue = 'YOUR_ENTITY_NAME'SINCE 7 days agoVulnerability breakdown by entity type
Analyze vulnerabilities across different entity types:
FROM VulnerabilitySELECT count(*) AS 'Vulnerabilities'FACET entityLookupValue, severity, entityTypeLIMIT 20SINCE 7 days agoEntities with no recent scans
Identify entities that may not be reporting vulnerability data:
FROM VulnerabilitySELECT max(timestamp) AS 'Last Scan'FACET entityLookupValueSINCE 30 days agoLIMIT 20Compliance and reporting
Vulnerabilities older than 30 days (SLA tracking)
Monitor vulnerabilities exceeding your remediation SLA:
FROM VulnerabilitySELECT count(*) AS 'Overdue Vulnerabilities'FACET entityLookupValue, severitySINCE 180 days agoUNTIL 30 days agoLIMIT 20Monthly vulnerability metrics
Generate monthly reports:
FROM VulnerabilitySELECT count(*) AS 'Total Detected', uniqueCount(entityGuid) AS 'Affected Entities', filter(count(*), WHERE severity IN ('CRITICAL', 'HIGH')) AS 'High Risk'FACET monthOf(firstDetected)SINCE 180 days agoTIMESERIES 1 monthAdvanced analysis
Vulnerability blast radius
Identify vulnerabilities affecting many entities:
FROM VulnerabilitySELECT count(entityGuid) AS 'Affected Entities', max(numeric(cvss.score)) AS 'CVSS'FACET cveLIMIT 20SINCE 30 days agoSecurity hygiene score
Calculate a custom security score:
FROM VulnerabilitySELECT 100 - ( filter(count(*), WHERE severity = 'CRITICAL') * 10 + filter(count(*), WHERE severity = 'HIGH') * 5 + filter(count(*), WHERE severity = 'MEDIUM') * 2 + filter(count(*), WHERE severity = 'LOW') * 0.5) AS 'Security Score'FACET entityLookupValueSINCE 7 days agoLIMIT 20Vulnerability trends by type
Compare application vs infrastructure vulnerabilities:
FROM VulnerabilitySELECT count(*) AS 'Vulnerabilities'FACET entityTypeTIMESERIES AUTOSINCE 30 days agoEntity-based security findings
Query current-state vulnerability data using the Entity event type. This approach is better suited for entity-centric questions than for timeseries trending:
FROM EntitySELECT count(*)WHERE type = 'SECURITY_FINDING' AND cve.id IS NOT NULLFACET cve.id, severitySINCE 7 days agoTip
Adding AND cve.id IS NOT NULL filters out misconfiguration and policy-type findings that have no CVE mapped, which would otherwise dominate the facet results. This query uses the Entity event type (NerdGraph entity search) rather than the Vulnerability event type — it reflects current entity state rather than an event stream, so it is not suited for TIMESERIES trending.
Using these queries
In the query builder
- Go to one.newrelic.com > All capabilities > Query your data
- Copy and paste any query from this page
- Click Run to see results
- Adjust time ranges and filters as needed
In custom dashboards
- Create a new dashboard or edit an existing one
- Add a widget and select Query builder
- Paste the query and configure visualization
- Save the widget to your dashboard
In alerts
- Go to Alerts > Create a condition
- Select NRQL query as the condition type
- Use queries that return counts or thresholds
- Configure alert thresholds and notification channels
For more information on alerting, see Set up vulnerability alerts.
Tips for customizing queries
Replace placeholders
'YOUR_ENTITY_NAME'- Replace with your actual entity name from theentityLookupValueattribute- Time ranges (e.g.,
SINCE 30 days ago) - Adjust to your needs
Combine with other data
NRQL does not support cross-event JOINs. To correlate vulnerability data with APM or Infrastructure metrics, use separate queries and combine the results in a dashboard. For example:
-- Vulnerability dataFROM VulnerabilitySELECT count(*) AS 'Vulnerabilities'FACET entityLookupValueSINCE 1 day ago-- APM transaction data (run as a separate query)FROM TransactionSELECT average(duration) AS 'Avg Response Time'FACET appNameSINCE 1 day agoExport results
All query results can be:
- Downloaded as CSV
- Added to dashboards
- Exported via API
- Shared with your team