Introduction

Apart from infrastructure metrics like CPU, memory, disk IO, etc., applications generate metrics based on their app logic. For example, DB applications can have several queries, several pending transactions, and so on; message broker applications can have several topics, several messages not delivered, and so on. These metrics are essential in debugging and finding out root-causing issues.

Kubernetes 2.0 provides a mechanism to display both application/workload metrics and the infrastructure metrics of pods.

Supported Workload Metrics

ConfigMap

All workload ConfigMaps share a consistent syntax. The key fields such as targetPodSelector, auth, and others are explained below, with examples from the opsramp-workload-metric-user-config. To view the current configuration, run:

kubectl get configmap opsramp-workload-metric-user-config -n <agent-installed-namespace>

Sample ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: opsramp-workload-metric-user-config
  namespace: opsramp-agent
data:
  workloads: |
    redis:
      - name: redis
        auth: none
        port: 6379
        collectionFrequency: 2m
        targetPodSelector:
          matchLabels:
            - key: app
              operator: ==
              value:
                - redis
      - name: redis-with-tls
        auth: tls
        certFile:
          source: secret
          value: default/redis-tls-client/redis-client.crt
        keyFile:
          source: secret
          value: default/redis-tls-client/redis-client.key
        port: 6379
        collectionFrequency: 2m
        targetPodSelector:
          matchLabels:
            - key: app
              operator: ==
              value:
                - redis-tls
      - name: redis-with-credentials
        auth: credentials
        userName:
          source: value
          value: sri
        password:
          source: configmap
          value: default/redis-config/REDIS_PASSWORD
        port: 6379
        collectionFrequency: 2m
        targetPodSelector:
          matchLabels:
            - key: app
              operator: ==
              value:
                - redis-creds

Configuration Parameters

FieldDescription
workload/applicationName of the workload/application.
nameUnique name for the workload configuration.
collectionFrequencyCollection frequency (e.g., 10s, 30m, 1h). Default value is 1m.
authAuthentication method (options: none, credentials, tls).
userNameUsername used for authentication.
passwordPassword used for authentication.
portPort number where metrics are exposed for the workload.
targetPodSelectorCriteria to select target pods. All specified conditions must match to select a pod.
matchLabelsSpecifies matching criteria for pod labels.
keyPod label key.
operatorOperator to compare the key (options: ==, !=, =, in, notin, exists, !exists).
valuePod label values as an array of strings.

Troubleshooting

If you encounter workload metrics related issues, see the Troubleshooting documentation.