Menu
Open source

Enable service graphs

A service graph is a visual representation of the interrelationships between various services. Service graphs help to understand the structure of a distributed system, and the connections and dependencies between its components.

The same service graph metrics can also be generated by Tempo. This is more efficient and recommended for larger installations. For a deep look into service graphs, visit this section.

Service graphs are also used in the application performance management dashboard. For more information, refer to the service graph view documentation.

Before you begin

Service graphs are generated in Grafana Alloy and pushed to a Prometheus-compatible backend. Once generated, they can be represented in Grafana as a graph. You need these components to fully use service graphs.

Enable service graphs in Grafana Alloy

Caution

Grafana Alloy is the new name for our distribution of the OTel collector. Grafana Agent has been deprecated and is in Long-Term Support (LTS) through October 31, 2025. Grafana Agent will reach an End-of-Life (EOL) on November 1, 2025. Read more about why we recommend migrating to Grafana Alloy.

To start using service graphs, enable the feature in the Alloy configuration.

The following example adds the http.method and http.target span attributes as Prometheus labels to the generated service graph metrics, before writing the metrics to the Grafana OTLP gateway. Received trace spans are immediately written to the OTLP gateway.

alloy
otelcol.receiver.otlp "default" {
  grpc {}
  http {}

  output {
    traces = [
      otelcol.connector.servicegraph.default.input,
      otelcol.exporter.otlp.default.input
    ]
  }
}

otelcol.connector.servicegraph "default" {
  dimensions = ["http.method", "http.target"]
  output {
    metrics = [otelcol.exporter.otlp.default.input]
  }
}

otelcol.exporter.otlp "default" {
  client {
    endpoint = env("OTLP_ENDPOINT")
  }
}

To see all the available configuration options, refer to the component reference.

Grafana

The same service graph metrics can also be generated by Tempo. This is more efficient and recommended for larger installations.

For additional information about viewing service graph metrics in Grafana and calculating cardinality, refer to the server side documentation.