Menu
Grafana Cloud Grafana Kubernetes Monitoring Configure Kubernetes Monitoring Configure Kubernetes Monitoring using Agent Operator

Configure Kubernetes Monitoring using Grafana Agent Operator

This guide shows how to deploy Grafana Agent Operator into a Kubernetes cluster to set up Kubernetes Monitoring. Agent Operator then deploys and configures Grafana Agent automatically using Kubernetes custom resource objects.

The telemetry data collected includes:

  • Kubernetes cluster metrics
    • kubelet and cadvisor cluster metrics
    • kube-state-metrics
  • Container logs
  • Kubernetes events

This configuration method provides you with preconfigured dashboards and alerts.

Before you start

To deploy Kubernetes Monitoring, you need:

  • A Kubernetes cluster, environment, or fleet you want to monitor
  • The kubectl, curl, and envsubst command-line tools
  • The helm command-line tool (optional)

Deploy Kubernetes Monitoring using Grafana Agent Operator

Important: You should have only one job scraping kube-state-metrics. If you have multiple scrape jobs running at the same time, you might see an error similar to the following when you try to view objects in Cluster navigation: execution: found duplicate series for the match group...

To deploy Kubernetes Monitoring using Grafana Agent Operator:

  1. Navigate to your Grafana Cloud instance and click the Kubernetes Monitoring icon (ship wheel).

  2. Click Start sending data.

    Kubernetes Monitoring displays the Configuration tab.

  3. Select a Prometheus data source and, optionally, a Loki data source if you want to send log data.

Install preconfigured dashboards and alerts

Note: You must have the Admin role to install dashboards and alerts.

To install the preconfigured dashboards and alerts:

  • Click Install dashboards and rules.

    Kubernetes Monitoring installs the preconfigured dashboards and rules. After you set up Kubernetes Monitoring, you can select the Dashboards tab to view your telemetry data.

Configure Grafana Agent Operator

To configure Grafana Agent Operator for Kubernetes Monitoring:

  1. Under Configuration Instructions, click Agent Operator.

  2. Click Agent Operator configuration instructions.

  3. Choose whether to configure using Helm by selecting With Helm or Without Helm.

Option 1: Configure using Helm

  1. Under Prerequisites (step 1), check that you have met the prerequisites and follow the instructions to complete them, if necessary.

  2. Under Install CRDs and deploy Agent Operator, click Copy to clipboard and run the provided helm commands in your terminal.

    Note: If you don’t want to use Helm, skip this section and follow the instructions to configure Grafana Agent Operator without Helm.

    To check that the CRDs are created, enter kubectl get crd. You should see a number of Grafana CRDs:

    grafanaagents.monitoring.grafana.com 
    integrations.monitoring.grafana.com
    loginstances.monitoring.grafana.com
    metricsinstances.monitoring.grafana.com
    podlogs.monitoring.grafana.com
    
  3. Under Deploy custom resources to collect metrics, logs, and events, enter your Namespace in the Namespace field and your Cluster in the Cluster field. The manifest definition below updates with the names you provide.

  4. Optionally, remove metrics, allow lists, logs, and events from the manifest by toggling off any of the following:

    • Include metrics?
    • Allow list?
    • Include logs?
    • Include events?
  5. Click Copy to clipboard under the manifest and save the contents as a YAML file.

  6. Deploy Agent Operator by entering the following line in your terminal, substituting in the path to the YAML file you saved:

    kubectl apply -f <path_to_manifest.yaml>
    

Option 2: Configure without using Helm

  1. Under Prerequisites (step 1), check that you have met the prerequisites and follow the instructions to complete them, if necessary.

  2. Under Install CRDs and deploy Agent Operator, click Copy to clipboard and run the provided commands in your terminal.

    To check that the CRDs are created, enter kubectl get crd. You should see a number of Grafana CRDs:

    grafanaagents.monitoring.grafana.com 
    integrations.monitoring.grafana.com
    loginstances.monitoring.grafana.com
    metricsinstances.monitoring.grafana.com
    podlogs.monitoring.grafana.com
    
  3. Under Deploy custom resources to collect metrics, logs, and events, enter your Namespace in the Namespace field and your Cluster in the Cluster field. The manifest definition below updates with the names you provide.

  4. Optionally, remove metrics, allow lists, logs, and events from the manifest by toggling off any of the following:

    • Include metrics?
    • Allow list?
    • Include logs?
    • Include events?
  5. Click Copy to clipboard under the manifest and save the contents as a YAML file.

  6. Deploy Agent Operator by entering the following line in your terminal, substituting in the path to the YAML file you saved:

    kubectl apply -f <path_to_manifest.yaml>
    

Complete the configuration

To finish up:

  1. Click Test and finish configuration.

    Grafana Agent begins collecting your Kubernetes telemetry data.

  2. Explore your deployment:

    • In the Cluster navigation tab, click your Namespace to view the grafana-agent StatefulSet, the grafana-agent-logs DaemonSet, and the ksm-kube-state-metrics deployment.
    • Click the kube-system Namespace to see Kubernetes-specific resources.
    • In the Nodes tab, click into the Nodes of your cluster to view their condition, utilization, and pod density.

Next steps

Explore your Kubernetes infrastructure to view the monitoring data.

If you find that you need to update your configuration, see Update Grafana Kubernetes components.

To monitor an app in your Kubernetes cluster, see the Monitor an app with Kubernetes Monitoring tutorial. You will learn how to deploy an instrumented three-tier (data layer, app logic layer, load-balancing layer) web application into a Kubernetes cluster, and leverage Kubernetes Monitoring to monitor the application.