Security Metrics Dashboards

Production-grade guide to security metrics dashboards covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.

Security metrics dashboards aggregate raw findings from scanning, testing, and governance tools into a single, time‑aware view. They matter when a team needs to track vulnerability trends across repositories, demonstrate compliance posture to auditors, or prioritize remediation work without chasing individual tickets. This page covers the practical steps of extracting metric data, getting it into a visualization system, and—crucially—recognizing the failure modes that make dashboards look healthy while hiding real risk.

Pull Raw Metrics from Scan Tools

The first step is getting structured data out of the tools that produce it. Most modern devsecops pipelines emit results as JSON, CSV, or log lines; the dashboard’s job is to consume those outputs consistently.

From container image scanning

trivy image alpine:3.18 --format json > trivy-alpine.json

If the image cannot be pulled, trivy exits with:

error: unable to pull image "alpine:3.18": context deadline exceeded

The resulting trivy-alpine.json contains an array of findings, each with a Severity, VulnerabilityID, PkgName, and InstalledVersion. That structure is what downstream ingestion expects.

From SAST/DAST job artifacts Many CI systems publish test results as SARIF or JSON artifacts. A typical curl fetch looks like:

curl -sSf https://ci.example.com/jobs/123/artifacts/raw/sast-report.json -o sast.json

If the job has not yet completed, the endpoint returns HTTP 404 with body:

Not found: job 123 still running

SARIF files share a common envelope shape (runs[0].results[]) that can be normalized into a flat table of file_path, rule_id, level, and message.

From ticketing systems Vulnerability tracking often lives in Jira, GitHub Issues, or Bugzilla. A parameterized query can pull open findings:

psql -U secuser -d ticketdb -c \
  "SELECT id, title, severity, created_at FROM issues WHERE component = 'web' AND status = 'open';"

If the severity column uses a non‑standard token (e.g., high instead of Critical), the dashboard query must map those values rather than assuming a fixed enum.

Ingest into a Time‑Series or Relational Store

Once raw outputs exist, they need a stable home for querying. The pattern chosen usually depends on whether the team already runs a Prometheus stack, has a PostgreSQL instance, or prefers a lightweight file‑based approach.

Prometheus remote write A lightweight exporter can push normalized counts into Prometheus. An example node script (JavaScript/Node) might:

  1. Read trivy-alpine.json
  2. Tally findings by Severity
  3. POST to http://localhost:9090/api/v1/write?job=trivy-repo:
curl -s -X POST http://localhost:9090/api/v1/write \
  --data-binary 'vuln_finding{severity="critical",repo="web-app"} 1704067200'

Prometheus accepts line‑protocol format; each data point needs a metric name, label set, and Unix timestamp. If the POST returns HTTP 400 with:

error while parsing line: unknown metric name 'vuln_finding'

the metric name must match a previously registered type or a metric_relabel_configs rule must be added.

PostgreSQL + scheduled script Teams already running PostgreSQL often prefer a cron‑driven loader. A bash‑psql pipeline might:

#!/usr/bin/env bash
json=$(cat trivy-alpine.json)
counts=$(echo "$json" | jq -r '[.Results[] | .Severity] | group_by . | .[] | {severity: .[0], count: length} | @json')
psql -U secuser -d secdb -c "INSERT INTO vuln_counts (severity, ts) VALUES ($(echo "$counts" | jq -r '.severity'), NOW());"

If the psql command fails because the vuln_counts table lacks a ts column, the error is:

ERROR: column "ts" does not exist

Adding the column (ALTER TABLE vuln_counts ADD COLUMN ts timestamptz;) resolves it.

Grafana dashboard JSON (as stored data, not runtime config) Dashboards are version‑controlled files written in JSON. A typical panel definition references a Prometheus data source and a query string; the file itself is plain text that can be edited, reviewed, and merged like any other code artifact. Teams keep these files in a Git repository and apply changes via pull requests, ensuring auditability and rollback capability.

Render in a Dashboard

With data in a time‑series store or relational table, panels are configured to surface the metrics the reader cares about.

Severity breakdown over time A Prometheus‑backed panel might plot:

count by (severity) (vuln_finding{job="trivy"})

The panel’s time range is typically set to “Last 30 days” with a monthly grain for trend visibility. If the query returns “no data for this interval,” it usually means the ingestion job has not run within the window or the job label does not match any active series.

Top‑affected services A table panel can surface the five repositories with the highest critical count:

topk(5, count by (repo) (vuln_finding{severity="critical"}))

The result appears as a table with columns repo and value (the count). If a repo name contains a Prometheus label special character (e.g., _ or /), the query must quote it or the series silently drops that series.

Compliance‑related aggregates For audit‑ready views, a panel might compute the ratio of “resolved” to “open” findings by querying a remediation table:

SELECT severity,
       COUNT(*) FILTER (WHERE status = 'resolved') AS resolved,
       COUNT(*) FILTER (WHERE status = 'open') AS open,
       ROUND(100.0 * COUNT(*) FILTER (WHERE status = 'resolved') / NULLIF(COUNT(*), 0), 2) AS resolution_rate
FROM vuln_counts v
JOIN remediation r USING (vuln_id, repo)
GROUP BY severity
ORDER BY severity;

If the remediation table uses a different primary key convention (e.g., issue_id instead of vuln_id), the join produces zero rows and the panel shows all zeros—no error is raised, but the dashboard silently misrepresents the posture.

Sharp Edges: What Silently Fails

Time‑window skew Scanning jobs often run at midnight UTC, while teams view dashboards in local time. A finding generated at 23:59 UTC on December 31 appears in the “Last 30 days” view starting January 1 in a UTC‑aligned dashboard, but in a local‑time view it may fall into the previous month’s bucket. The visual gap is invisible unless the dashboard’s timezone is explicitly set and communicated.

Severity label collision Two distinct tools may tag the same CVE as critical without sharing a CVSS threshold. One tool might use CVSS ≥ 7.0, another CVSS ≥ 9.0. When both series are summed under the same severity="critical" label, the dashboard inflates the count. The only reliable fix is to normalize severity at ingestion time, mapping each tool’s tag to a single canonical enum before writing to the store.

Aggregation drift Summing count across a repo label without grouping yields cluster‑wide numbers that hide per‑repo hotspots. A dashboard showing “12 critical findings” may have one repository holding 11 of them. Breaking the panel out by repo (by (repo) (vuln_finding{severity="critical"})) reveals the distribution, but adds rendering cost and requires the reader to scroll.

Authentication token expiration Many teams expose a read‑only token to the metrics API for dashboard ingestion. Tokens have a finite lease period (often 30 days). When the token expires, curl attempts the POST and receives HTTP 401:

Unauthorized: authentication token has expired

Panels go blank. Because most dashboard UIs do not surface the underlying HTTP status, the outage appears as “no data” with no immediate clue that auth is the cause. Rotating tokens via a secret manager and configuring the exporter to retry on 401 is the standard mitigation.

Stale‑data silence A scan tool that last ran 45 days ago may still appear in a “last run” panel if the panel only checks a started_at timestamp rather than a finished_at field. The panel shows a green “last run: 2025‑02‑10” while the data it displays is over a month old. Adding a WHERE finished_at > now() - interval '7 days' filter eliminates this class of stale display.

Maintenance and Evolution

Query as code Treat PromQL, SQL, or Grafana panel JSON as source code. Store them in the same repository as the CI pipelines that produce the raw metrics. A change to a query string is a pull request; a failed merge can be reverted instantly. Linting tools such as promtool check queries can validate Prometheus queries before they hit the server:

promtool check queries /path/to/queries.yaml

If the file contains a syntax error—such as an unmatched parenthesis—promtool exits with:

error: parse error at line 4: unclosed '('

The fix is straightforward: correct the parenthesis balance and re‑run the check.

Onboarding new data sources When a new scan tool is added, the ingestion pipeline must map its output schema to the canonical metric name and label set. A common pattern is a small transformation script that reads the tool’s JSON, normalizes severity values, and writes line‑protocol to Prometheus. The script is version‑controlled alongside the dashboard definitions, so any drift in the tool’s output format triggers a CI failure (e.g., jq returns null for an expected field), prompting an update before the dashboard is redeployed.

Drift detection Periodic audits compare the set of active series in Prometheus against the expected list derived from the CI pipeline’s repository inventory. A simple script can curl the series endpoint and diff the result:

curl -s http://localhost:9090/api/v1/series?match[]={job="trivy"} | jq -r '.data[].metric.repo' | sort > /tmp/active_repos.txt
comm -23 /tmp/active_repos.txt /tmp/expected_repos.txt

Any entries appearing in active_repos.txt but not in expected_repos.txt signal a pipeline gap or a rogue scan run. The diff is captured in the audit log; persistent unknown repos trigger a Slack alert.

Dashboard refresh storms When many panels query the same metric with short refresh intervals (e.g., every 15 seconds), the cumulative load on the metrics store can cause temporary query throttling. Panels start returning “query timeout after 30s” and the dashboard flickers. The recommended pattern is to align refresh rates: coarse trends at 5 minutes, detailed tables at 30 seconds, and alert‑linked panels at 1 minute. Adjusting the grafana.ini refresh_interval and per‑panel refresh settings prevents unnecessary strain.

Building and maintaining a security metrics dashboard is less about choosing the right vendor’s UI and more about reliably moving raw findings into a queryable store, rendering them with transparent queries, and guarding against the silent failure modes that turn a “green” dashboard into a blind spot. The patterns above—trivy → JSON → Prometheus line‑protocol → panel query, or raw SARIF → PostgreSQL → SQL panel—are repeatable, auditable, and resilient when treated as code and monitored for the edge cases that inevitably appear in production environments.

This page was rewritten on 12 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.