Documentationbreadcrumb arrow Grafana Cloudbreadcrumb arrow Platformbreadcrumb arrow Knowledge graphbreadcrumb arrow Referencebreadcrumb arrow Understand how the knowledge graph processes data
Grafana Cloud

How the knowledge graph processes data

The knowledge graph builds itself from the telemetry you already send. You don’t draw the graph. The knowledge graph reads the labels on your metrics to discover entities and the relationships between them, derives a standard set of key performance indicators (KPIs) for those entities, and evaluates alert rules over those KPIs to produce insights, which are signals that something needs attention.

Every stage has built-in rules that work with standard OpenTelemetry and Prometheus metrics. The knowledge graph also has built-in knowledge of common cloud platforms, runtimes, and frameworks, so it recognizes their telemetry without extra configuration. You can extend every stage with your own rules.

Stage summary

The following table summarizes what happens to a metric at each stage and how you can extend that stage.

StageWhat happensHow you can extend it
1. Ingest metricsThe metric arrives in your stack with the labels its source attached.The configuration of your metric source
2. Normalize labelsLabels that identify the environment, region, and service are copied into standard knowledge graph labels such as asserts_env and asserts_site.The mapping from your labels to the standard labels
3. Discover entitiesEntity rules read label sets and create or update entities, such as a Service or a Pod.Custom entity rules, using gcx kg model-rules or the Entity & Relation rules page
4. Establish relationshipsRelationship rules connect the discovered entities, for example with a CALLS relationship between two services.Custom relationship rules, using gcx kg model-rules or the Entity & Relation rules page
5. Normalize KPIsMany metric shapes are converted into a small, common set of KPIs: request rate, error ratio, average latency, and latency percentiles.Custom KPI mappings, using the RED mapping page
6. Derive insightsAlert rules evaluate the KPIs and produce insights, attached to the entity they describe.Custom alert rules, using gcx kg prom-rules. You can silence an insight with a suppression.

The rest of this topic follows one metric through each stage.

Example metric

This example follows http_server_request_duration_seconds, the OpenTelemetry HTTP server histogram, for a service called checkout in the shop namespace, running in the prod environment in the us-east region. In Prometheus format, the histogram arrives as _bucket, _sum, and _count series. Each series carries the labels its source attached, for example:

http_server_request_duration_seconds_count{
  service_name="checkout", service_namespace="shop",
  http_request_method="POST", http_route="/cart/{id}",
  http_response_status_code="503"
}

Stage 1: Ingest metrics

The metric reaches your stack with the labels its source attached. The source can be an OpenTelemetry SDK, the OpenTelemetry Collector, Grafana Alloy, a Prometheus scraper, or metrics that Grafana Cloud generates for you. At this point, the series carries only the labels from its source, including whatever labels your telemetry uses for environment and region.

Stage 2: Normalize labels

Different sources use different names for the same idea. As each series is written, the knowledge graph fills in a small set of standard labels. It only fills a label when it’s empty, so any value you set yourself is kept.

LabelValue for the example metricWhy it matters
asserts_envprod, set at the source or copied from the environment label you mapSplits the graph into environments
asserts_siteus-east, set at the source or copied from the region label you mapSplits the graph into sites (regions)
serviceCopied from service_nameIdentifies the Service entity
namespaceThe first of k8s_namespace_name or service_namespaceScopes the entity
asserts_request_contextThe method and route, for example POST /cart/{id}Lets KPIs be split by endpoint
asserts_request_typeinbound for the server histogram, outbound for the client histogramSeparates traffic a service serves from calls it makes
asserts_error_typeserver_errors for 5xx status codes, client_errors for 4xx status codesMarks which series count as errors

The asserts_ prefix marks a label as internal to the knowledge graph. The asserts_env and asserts_site labels split one graph into environments, such as prod and staging, and sites, such as us-east, while keeping everything in a single graph so you can compare across environments.

You can set asserts_env and asserts_site at the source or with your own relabeling. If they aren’t already on a series, the knowledge graph copies them from the labels you map when you set up your environment. You can map any existing label, so the environment and region labels your telemetry already carries are enough. To view the rules that set these labels in your stack, run gcx kg relabel-rules get.

The later stages only process series that have an asserts_env value, and skip series that don’t. OpenTelemetry application metrics are handled differently: when they carry no environment label, they fall back to asserts_env="unknown", so they’re still included. For details on how the knowledge graph chooses environment values, refer to Environment and region.

Stage 3: Discover entities

An entity is a component of your system with a type, a name, and properties. An entity rule specifies which metric to read, which labels identify the entity, and which labels become properties.

For OpenTelemetry services, the built-in rule reads the target_info series that your SDK or collector emits. The rule identifies the entity by service name, namespace, environment, and site. From the example metric, the graph holds one entity:

Service  name=checkout  namespace=shop  env=prod  site=us-east
         properties: service_version, telemetry_sdk_language, deployment_environment, ...

Discovery runs on a regular cycle. When an entity stops appearing in your telemetry, the knowledge graph marks it as expired instead of deleting it, so you can still see what your system looked like during a past incident.

Stage 4: Establish relationships

A relationship rule describes how to connect entities discovered in the previous stage. The rule can compare properties of two entities, or run a Prometheus query and draw one relationship for each result. A query can read a single metric or join more than one.

For example, service graph metrics produce CALLS relationships between services:

(Service checkout)-[:CALLS]->(Service payments)

Relationships expire in the same way as entities.

Stage 5: Normalize KPIs

Dashboards and alerts written for individual metrics don’t scale across hundreds of technologies. For each telemetry source, the knowledge graph knows which metrics hold the request count, the error count, the request duration, and the latency histogram. It uses them to compute the same small set of KPIs for every service, and tags each result with an entity type, so one set of insight rules works for every technology.

Each KPI is computed per service over a 5-minute window:

KPIHow it’s computed
Request rate (asserts:request:rate5m)rate(<request counter>[5m])
Error ratio (asserts:error:ratio)rate(<error counter>[5m]) / rate(<request counter>[5m]), capped at 1
Average latency (asserts:latency:average)rate(<duration sum>[5m]) / rate(<duration count>[5m]), with milliseconds and microseconds converted to seconds
Latency percentiles, such as p99 (asserts:latency:p99)histogram_quantile over the source’s histogram, which can be a classic histogram or a native histogram

For a classic histogram, the percentile is computed from the bucket series:

promql
histogram_quantile(0.99, sum by (le, ...) (rate(<metric>_bucket[5m])))

For a native histogram, it’s computed from the histogram series itself:

promql
histogram_quantile(0.99, sum by (...) (rate(<metric>[5m])))

To see what this looks like, take the example metric, the OpenTelemetry server duration histogram. It’s made of the metric family http_server_request_duration_seconds_[sum|count|bucket]. With the template filled in, the KPIs are:

promql
# Request rate
rate(http_server_request_duration_seconds_count[5m])

# Error ratio
rate(http_server_request_duration_seconds_count{http_response_status_code=~"5.."}[5m])
  / rate(http_server_request_duration_seconds_count[5m])

# Average latency
rate(http_server_request_duration_seconds_sum[5m])
  / rate(http_server_request_duration_seconds_count[5m])

# p99 latency
histogram_quantile(0.99, sum by (le, ...) (rate(http_server_request_duration_seconds_bucket[5m])))

The metric already reports seconds, so no unit conversion is needed. Each result is labeled with the Service entity it belongs to, checkout in shop, prod, and us-east.

To map a metric that the knowledge graph doesn’t recognize to these KPIs, refer to Map Prometheus metrics to RED KPIs. For the insights that each KPI feeds, refer to Default KPI-based insights.

Stage 6: Derive insights

Alert rules over the normalized KPIs produce insights. Insights aren’t designed to notify on-call staff. They act as the vital signs of your system, ready when you investigate. You can subscribe to specific insights if you want to use them as traditional alerts.

Each insight has a severity and a category. The categories follow the SAAFE model:

CategoryMeaningExample insight
SaturationA resource is close to its limit.Saturation
AmendA change to the system, such as a rollout or a scaling event, that’s useful to correlate with other insights.Defined by amend rules
AnomalyA KPI left its usual range, learned from the previous days and weeks.RequestRateAnomaly, ErrorRatioAnomaly
FailureSomething stopped working or is in an invalid state.Defined by failure rules
ErrorA KPI crossed a threshold.ErrorRatioBreach

The knowledge graph attaches each insight to an entity through the same labels that identify the entity: environment, site, namespace, and service. In the example, a spike in 5xx responses from checkout in prod appears as an ErrorRatioBreach insight on that one Service entity.

For the full list of categories, refer to Insights categories. For the insights that the built-in rules raise, refer to Base rules and framework-specific rules.

How insights connect across the graph

After an insight fires, the knowledge graph:

  • Attaches the insight to the graph and indexes it for search, so a single search can find both entities and their health status.
  • Adds context from the graph to the insight. For example, an insight raised on a Pod is also associated with the node and the service that the Pod belongs to. Insights on short-lived entities, such as Pods, then appear on long-lived entities, such as nodes and services, which gives you a continuous timeline.

Because insights are condensed and placed in context, they’re fast to query, aggregate, correlate, and rank during root cause analysis.

Query the results

After the six stages run, you can explore entities, relationships, and insights in Grafana Cloud, or query them from scripts and agents with gcx.

To look up an entity and its properties, run:

Bash
gcx kg entities list --type Service --env prod --namespace shop --property name=checkout

To view the insights and related entities of an entity during an incident window, run:

Bash
gcx kg entities inspect --type Service --name checkout --env prod --namespace shop \
  --from 2026-10-20T09:00:00Z --to 2026-10-20T10:00:00Z

To find the services that an entity calls, run a read-only Cypher query. Every gcx kg graph query requires a literal LIMIT.

Bash
gcx kg graph query "MATCH (a:Service {name:'checkout'})-[:CALLS]->(b:Service) RETURN a, b LIMIT 25"

Next steps