Help build the future of open source observability software Open positions

Check out the open source projects we support Downloads

Grot cannot remember your choice unless you click the consent notice at the bottom.

Grafana Agent v0.31 release: new Helm chart, Flow support for Grafana Phlare, and more

Grafana Agent v0.31 release: new Helm chart, Flow support for Grafana Phlare, and more

1 Feb, 2023 5 min

In March 2023, Grafana Labs acquired Pyroscope, the company behind the eponymous open source continuous profiling project. As a result, the Pyroscope and Grafana Phlare projects will be merged under the new name Grafana Pyroscope. To learn more, read our recent blog post about the news.
15 Mar 2023

Here at Grafana Labs, we aim to create products which integrate well with open standards and are easy to install everywhere. Today, we’re excited to announce Grafana Agent v0.31, which allows you to connect to even more types of observability signals for both scraping and remote writes. And to help you install the Agent more easily, there is now an official Windows Docker image and an official Helm Chart.

Here’s a breakdown of the latest features and upgrades in Grafana Agent v0.31.

Deploy Grafana Agent in Kubernetes with an official Helm Chart

If an Agent needs to run in a Kubernetes cluster, it can now be installed easily via the officially supported Helm Chart available on ArtifactHub. Its code is available on our GitHub repository in case you would like to contribute to it or just to inspect it.

helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana-agent grafana/grafana-agent

Install Grafana Agent in Windows containers via our new Docker image

It is now also possible to install the Agent to a Windows container via an official image on DockerHub. To install it via cmd.exe, simply run a command like this:

docker run ^
  -v c:\grafana-agent-data:c:\etc\grafana-agent\data ^
  -v c:\workspace\config\grafana-agent:c:\etc\grafana-agent ^
  grafana/agent:v0.31.0-windows`

For more information on container deployments, please refer to our Grafana Agent documentation.

Collect profiling data for Grafana Phlare

Grafana Phlare is Grafana Labs’ new open source project for continuous profiling. You can now use the Grafana Agent to pull data from scrape targets in Google’s pprof format and send it to a Phlare database for storage. This can be as simple as using just two new Grafana Agent Flow components — phlare.scrape and phlare.write.

phlare.scrape "default" {
  // Scrape two local applications - the Agent itself and Phlare
  targets = [
    {"__address__" = "phlare:4100", "app"="phlare"},
    {"__address__" = "agent:12345", "app"="agent"},
  ]

  // Send the scraped data to the phlare.write component
  forward_to = [phlare.write.staging.receiver]
}

phlare.write "staging" {
  // Send profiles to a locally running Phlare instance.
  endpoint {
    url = "http://phlare:4100"

    // Headers to include in the HTTP request to Phlare
    headers = {
      "X-Scope-Org-ID" = "squad-1",
    }
  }

  // Labels to add to the profiles which Agent is sending to Phlare
  external_labels = {
    "env" = "staging",
  }
}

You can also leverage Flow components discovery.kubernetes and discovery.relabel to automatically discover and scrape Kubernetes pods profiles.

discovery.kubernetes "phlare_kubernetes" {
  role = "pod"
}

discovery.relabel "phlare_relabel" {
  rule {
    action = "labelmap"
    regex = "__meta_kubernetes_pod_label_(.+)"
  }
  rule {
    action = "replace"
    source_labels = ["__meta_kubernetes_namespace"]
    target_label = "namespace"
  }
  rule {
    action = "replace"
    source_labels = ["__meta_kubernetes_pod_name"]
    target_label = "pod"
  }
  rule {
    action = "replace"
    source_labels = ["__meta_kubernetes_pod_container_name"]
    target_label = "container"
  }
  targets = concat(discovery.kubernetes.phlare_kubernetes.targets)
}

phlare.scrape "default" {
  forward_to = [phlare.write.staging.receiver]
  targets = discovery.relabel.phlare_relabel.output
}

Going forward, Grafana Agent will be the default agent for Grafana Phlare, and we plan to implement more profiling features in the future.

To get started with continuous profiling, check out our recent blog post about Grafana Phlare!

Configure Grafana Mimir with PrometheusRule CRDs

Thanks to the new mimir.rules.kubernetes Flow component, the Grafana Agent can now auto-discover Kubernetes resources from the PrometheusRule CRD of the Prometheus Operator and load them into a Grafana Mimir instance. An example Agent configuration would look like this:

mimir.rules.kubernetes "local" {
    address = "mimir:8080"
    tenant_id = "team-a"

    // Only rules and namespaces with the “agent” label set to “yes” are included.
    rule_namespace_selector {
        match_labels = {
            agent = "yes",
        }
    }
    rule_selector {
        match_labels = {
            agent = "yes",
        }
    }
}

Prometheus Rules allow users to precompute frequently needed or computationally expensive expressions and save their result as a new set of time series. Grafana Mimir supports the Rule format in its ruler component. The rules could then be used either for alerting or for improving the query time of PromQL queries.

Convert logs from OpenTelemetry format to Grafana Loki format

Would you like to receive OpenTelemetry log data via gRPC and send it over to Loki? With the release of Grafana Agent v0.31, this is now possible: The new otelcol.exporter.loki component can convert any OpenTelemetry-formatted logs to the Grafana Loki format, so that the Agent can send them to a Loki instance, like this:

otelcol.receiver.otlp "default" {
  grpc {
        endpoint = ”0.0.0.0:4317”
  }

  output {
    logs = [otelcol.exporter.loki.default.input]
  }
}

otelcol.exporter.loki "default" {
  forward_to = [loki.write.local.receiver]
}

loki.write "local" {
    endpoint {
        url = "loki:3100"
    }
}

The Agent example above receives OpenTelemetry logs on the 0.0.0.0:4317 address, and forwards them to a Loki instance on the loki:3100 address.

Convert logs from Grafana Loki format to OpenTelemetry format

The opposite conversion, from a Grafana Loki format to an OpenTelemetry format, is now possible via the otelcol.receiver.loki component. This allows you to ingest logs via any of our many loki.source. components, process them via loki.process, and then send them to either a Grafana Loki database, an OpenTelemetry-compatible endpoint, or both.

How to upgrade or get started with the Grafana Agent

If you are new to the Grafana Agent, there are two ways to get started:

  1. The future of the Agent is Grafana Agent Flow. It is currently in beta, but if you would like to try it, you could begin with our Flow documentation and then move on to one of the tutorials.
  2. To get started with the stable (non-Flow) part of the Agent, please see our quick start guide.

The full set of new features in the v0.31.0 is listed in our release notes on GitHub. For a list of deprecated features and breaking changes, you can go directly to the Agent upgrade guide in our documentation.

We are always happy to speak with the community! Please reach out to us on any one of the following channels:

Grafana Cloud is the easiest way to get started with metrics, logs, traces, and dashboards. We have a generous free forever tier and plans for every use case. Sign up for free now!