EKS telegraf, how to obtain labels like workergroup

We want to collect data from EKS using Telegraf, and one of the tags we want to use is workergroups . Is it possible to collect the tags that Node Exporter can collect using Telegraf?

@Acf Welcome to the Influxdata community

Yes, you can collect EKS workergroup tags using Telegraf. Here’s how to set this up:

Telegraf can access EKS workergroup labels through its Kubernetes input plugin, which can collect metadata from your Kubernetes cluster, including node labels where the workergroup information is stored.

The key steps are:

  1. Configure Telegraf with the Kubernetes input plugin
  2. Set up proper RBAC permissions so Telegraf can access node information
  3. Filter for the specific labels you need (like the workergroup tag)

For an EKS cluster, AWS typically adds labels to nodes that identify their workergroup, usually in the format eks.amazonaws.com/nodegroup or similar.

Here’s a basic configuration example for your Telegraf config:

[[inputs.kubernetes]]
  ## URL for the Kubernetes API
  url = "https://kubernetes.default.svc"
  
  ## Collect node metrics
  node_meta_include = ["eks.amazonaws.com/nodegroup"]
  
  ## Use service account token for authentication
  bearer_token = "/var/run/secrets/kubernetes.io/serviceaccount/token"
  
  ## Verify TLS certificate
  insecure_skip_verify = false

Make sure Telegraf runs with a service account that has permissions to read node information. You’ll need a ClusterRole and ClusterRoleBinding like this:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: telegraf-reader
rules:
- apiGroups: [""]
  resources: ["nodes"]
  verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: telegraf-reader-binding
subjects:
- kind: ServiceAccount
  name: telegraf
  namespace: monitoring
roleRef:
  kind: ClusterRole
  name: telegraf-reader
  apiGroup: rbac.authorization.k8s.io

This should allow Telegraf to collect the workergroup information from your EKS cluster similar to how Node Exporter would capture it.

1 Like

Thanks for your reply, Skartikey. I’ll try to do that and reply soon.