Skip to content

vmagent

Field Description Scheme
install Allows to enable or disable deploy vmagent. boolean
image A Docker image to deploy the vmagent. string
resources The resources that describe the compute resource requests and limits for single pods. v1.ResourceRequirements
securityContext SecurityContext holds pod-level security attributes. Default for Kubernetes, securityContext:{ runAsUser: 2000, fsGroup: 2000 }. *v1.PodSecurityContext
containers Containers property allows to inject additions sidecars or to patch existing containers. It can be useful for proxies, backup, etc. []v1.Container
paused Set paused to reconciliation for vmagent boolean
tolerations Tolerations allow the pods to schedule onto nodes with matching taints. []v1.Toleration
nodeSelector Defines which nodes the pods are scheduled on. Specified just as map[string]string. For example: \"type: compute\" map[string]string
affinity If specified, the pod's scheduling constraints *v1.Affinity
labels Map of string keys and values that can be used to organize and categorize (scope and select) objects. Specified just as map[string]string. For example: "label-key: label-value" map[string]string
annotations Map of string keys and values stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. Specified just as map[string]string. For example: "annotations-key: annotation-value" map[string]string
ingress Ingress allows to create Ingress for the vmagent UI. *Kubernetes Ingress
httpRoute HTTPRoute allows to create Gateway API HTTPRoute for the vmagent UI. HTTPRouteSpec
scrapeInterval Defines how often scrape targets by default. string
additionalScrape The additionalScrape allows you to monitor hosts outside the cloud (balancers, graylog server, jenkins...) *v1.SecretKeySelector, Victoria Metrics Config
vmAgentExternalLabelName Name of vmAgent external label used to denote VmAgent instance name. Defaults to the value of vmagent. External label will not be added when value is set to empty string (""). string
externalLabels The labels to add to any time series scraped by vmagent. It doesn't affect metrics ingested directly by push APIs map[string]string
remoteWriteSettings Defines global settings for all remoteWrite URLs. For more information, refer to the VMAgent documentation. *v1beta1.VMAgentRemoteWriteSettings
remoteWriteSettings.maxDiskUsagePerURL The maximum file-based buffer size in bytes at -remoteWrite.tmpDataPath for each -remoteWrite.url. Disk usage is unlimited if the value is set to 0. For more information, refer to the VMAgent documentation. string
remoteWriteSettings.showURL Whether to show -remoteWrite.url in the exported metrics. It is hidden by default, since it can contain sensitive auth info string
remoteWriteSettings.label Optional labels in the form 'name=value' to add to all the metrics before sending them string
remoteWrite RemoteWriteSpec defines the remote_write configuration for vmagent. The remote_write allows to transparently send samples to a long term storage. For more information, refer to the VMAgent documentation. []v1beta1.VMAgentRemoteWriteSpec
remoteWrite.url URL of the endpoint to send samples to. string
remoteWrite.basicAuth Allow an endpoint to authenticate over basic authentication. *v1beta1.BasicAuth
remoteWrite.basicAuth.createSecret Allow create secret for basic authentication automatically. map[string]string
remoteWrite.basicAuth.createSecret.secretName Name of the secret with which will be created. string
remoteWrite.basicAuth.createSecret.username Username for basic authentication. string
remoteWrite.basicAuth.createSecret.password Password for basic authentication. string
remoteWrite.bearerTokenSecret Optional bearer auth token to use for -remoteWrite.url. *v1.SecretKeySelector
remoteWrite.oauth2 Defines auth configuration. *v1beta1.OAuth2
remoteWrite.tlsConfig Describes tls configuration for remote write target. *v1beta1.OAuth2
remoteWrite.urlRelabelConfig ConfigMap with relabeling config which is applied to metrics before sending them to the corresponding -remoteWrite.url. See the relabeling documentation. *v1.ConfigMapKeySelector
remoteWrite.inlineUrlRelabelConfig Defines relabeling config for remoteWriteURL, it can be defined at crd spec. See the relabeling documentation. []RelabelConfig
urlRelabelConfig ConfigMap with global relabel config -remoteWrite.relabelConfig. This relabeling is applied to all the collected metrics before sending them to remote storage. See the relabeling documentation. *v1.ConfigMapKeySelector
inlineUrlRelabelConfig Defines GlobalRelabelConfig for vmagent, can be defined directly at CRD. See the relabeling documentation. []RelabelConfig
podMonitorNamespaceSelector Defines Namespaces to be selected for VMPodScrape discovery. *metav1.LabelSelector
serviceMonitorNamespaceSelector Defines Namespaces to be selected for VMServiceScrape discovery. *metav1.LabelSelector
podMonitorSelector Defines PodScrapes to be selected for target discovery. *metav1.LabelSelector
serviceMonitorSelector Defines ServiceScrapes to be selected for target discovery. *metav1.LabelSelector
extraArgs List of key-value with additional arguments which will be passed to VMAgent pod. See VictoriaMetrics command-line flags. map[string]string
extraEnvs Allow to set extra system environment variables for vmagent. []v1.EnvVar
secrets Secrets is a list of Secrets in the same namespace as the VMSingle object, which shall be mounted into the vmagent pods []string
volumes Volumes allows configuration of additional volumes on the output deploy definition. Volumes specified will be appended to other volumes that are generated as a result of StorageSpec objects []v1.Volume
volumeMounts VolumeMounts allows configuration of additional VolumeMounts on the output deploy definition. VolumeMounts specified will be appended to other VolumeMounts in the vmsingle container that are generated as a result of StorageSpec objects []v1.VolumeMount
maxScrapeInterval MaxScrapeInterval allows limiting maximum scrape interval for VMServiceScrape, VMPodScrape and other scrapes string
minScrapeInterval MinScrapeInterval allows limiting minimal scrape interval for VMServiceScrape, VMPodScrape and other scrapes string
priorityClassName PriorityClassName assigned to the Pods to prevent them from evicting string
tlsConfig TLS configuration for VMAgent. Must be specified if victoriametrics.tlsEnabled is set to true TLSConfig

Security hardening

VMAgent uses the common non-root, read-only-root-filesystem security baseline. Unlike other VictoriaMetrics components, its custom resource does not mount the hardening emptyDir over /tmp. VictoriaMetrics Operator mounts the VMAgent persistent queue at /tmp/vmagent-remotewrite-data; another volume mounted over the parent /tmp directory prevents the operator from reconciling VMAgent.

VictoriaMetrics Operator creates the persistent-queue-data emptyDir without a Kubernetes sizeLimit. VMAgent limits each remote-write queue through remoteWriteSettings.maxDiskUsagePerURL, which defaults to 1 GiB in VictoriaMetrics Operator 0.73.1. A Kubernetes volume limit must account for every configured remote-write URL and queue overhead. The monitoring operator therefore does not impose its generic 100Mi temporary-volume limit on the persistent queue. Configure remoteWriteSettings.maxDiskUsagePerURL according to the available ephemeral storage. The PlatformMonitoring VMAgent API does not expose the upstream stateful mode. Supporting a queue that survives pod replacement requires a separate API extension.

Do not add a VMAgent-level volume mount at /tmp. Containers listed in containers receive the container security baseline but no temporary volume, because the VMAgent custom resource declares none. A sidecar that needs a writable /tmp must declare its own volume in volumes and mount it in the sidecar's volumeMounts.

Example:

  vmAgent:
    install: true
    route:
      install: true
      host: vmagent.test.org
    logLevel: WARN
    serviceMonitor:
      interval: 29s
      scrapeTimeout: 9s
    extraArgs:
      loggerFormat: default
    remoteWriteSettings:
      label:
        project: development
        environment: qa-kuber-test
        cluster: qa-kuber-test
        team: test_team-test
      showURL: true
    remoteWrite:
      - url: https://remotehost-1:8429/api/v1/write
        basicAuth:
          username:
            key: username
            name: vmsecret
          password:
            key: password
            name: vmsecret
        tlsConfig:
          insecureSkipVerify: true
        urlRelabelConfig:
          name: "vmagent-relabel"
          key: "target-1-relabel.yaml"
        inlineUrlRelabelConfig:
          - source_labels: [__name__]
            separator: ;
            regex: kube.*
            replacement: $1
            action: keep
      - url: https://remotehost-2:8429/api/v1/write
        basicAuth:
          createSecret:
            username: user
            password: pass
            secretName: vmsecret-basicauth
        tlsConfig:
          insecureSkipVerify: true
        urlRelabelConfig:
          name: "vmagent-relabel"
          key: "target-1-relabel.yaml"
        inlineUrlRelabelConfig:
          - source_labels: [__name__]
            separator: ;
            regex: kube.*
            replacement: $1
            action: keep
    nodeSelector:
      role: compute
    labels:
      label: label_vmagent
    annotations:
      annotation: test_vmagent
    secrets:
      - kube-etcd-client-certs

TLSConfig

If TLS is enabled for Victoriametrics:

victoriametrics:
  tlsEnabled: true
  clusterIssuerName: dev-cluster-issuer
  vmAgent:
    install: true
    route:
      install: true
      host: vmagent.test.org
    logLevel: WARN
    serviceMonitor:
      interval: 29s
      scrapeTimeout: 9s
    extraArgs:
      loggerFormat: default
    remoteWriteSettings:
      label:
        project: development
        environment: qa-kuber-test
        cluster: qa-kuber-test
        team: test_team-test
      showURL: true
    remoteWrite:
      - url: https://remotehost-1:8429/api/v1/write
        basicAuth:
          username:
            key: username
            name: vmsecret
          password:
            key: password
            name: vmsecret
        tlsConfig:
          insecureSkipVerify: true
        urlRelabelConfig:
          name: "vmagent-relabel"
          key: "target-1-relabel.yaml"
        inlineUrlRelabelConfig:
          - source_labels: [__name__]
            separator: ;
            regex: kube.*
            replacement: $1
            action: keep
      - url: https://remotehost-2:8429/api/v1/write
        basicAuth:
          createSecret:
            username: user
            password: pass
            secretName: vmsecret-basicauth
        tlsConfig:
          insecureSkipVerify: true
        urlRelabelConfig:
          name: "vmagent-relabel"
          key: "target-1-relabel.yaml"
        inlineUrlRelabelConfig:
          - source_labels: [__name__]
            separator: ;
            regex: kube.*
            replacement: $1
            action: keep
    nodeSelector:
      role: compute
    labels:
      label: label_vmagent
    annotations:
      annotation: test_vmagent
    secrets:
      - kube-etcd-client-certs
    tlsConfig:
      generateCerts:
        enabled: false
      createSecret:
        secretName: "vmagent-tls-secret"
        ca: |-
          -----BEGIN CERTIFICATE-----
          ...
          -----END CERTIFICATE-----
        key: |-
          -----BEGIN PRIVATE KEY-----
          ...
          -----END PRIVATE KEY-----
        cert: |-
          -----BEGIN CERTIFICATE-----
          ...
          ------END CERTIFICATE-----