### Start vmalert Demo with Docker Compose Source: https://docs.victoriametrics.com/guides/vmalert-datasource-managed-alerts-grafana/index.html Use this command to start the vmalert demo environment using Docker Compose. Ensure Docker is installed and running. ```bash docker compose up -d ``` -------------------------------- ### Run Direct Sending Example Application Source: https://docs.victoriametrics.com/guides/getting-started-with-opentelemetry/index.html Start the Go web server that sends telemetry data directly to VictoriaMetrics and VictoriaLogs. ```bash go run main.go ``` -------------------------------- ### VMAnomaly Setup with Periodic Scheduler and Z-score Model Source: https://docs.victoriametrics.com/operator/resources/vmanomaly/index.html This example shows a basic VMAnomaly setup. It configures a periodic scheduler to run every minute, a Z-score model with a threshold of 2.5, and specifies data ingestion using a given query from a reader datasource. ```yaml apiVersion: operator.victoriametrics.com/v1 kind: VMAnomaly metadata: name: example spec: replicaCount: 1 license: key: "xx" reader: datasourceURL: http://vmsingle-read-example:8428 samplingPeriod: 10s writer: datasourceURL: http://vmsingle-write-example:8428 configRawYaml: |- reader: queries: ingestion_rate: expr: 'sum(rate(vm_rows_inserted_total[5m])) by (type) > 0' step: '1m' schedulers: scheduler_periodic_1m: class: "periodic" # class: "periodic" # or class: "scheduler.periodic.PeriodicScheduler" until v1.13.0 with class alias support) infer_every: "1m" fit_every: "2m" fit_window: "3h" models: model_univariate_1: class: 'zscore' z_threshold: 2.5 ``` -------------------------------- ### Run OpenTelemetry Example Application Source: https://docs.victoriametrics.com/guides/getting-started-with-opentelemetry/index.html Execute the Go application to start the dice roll web server instrumented with OpenTelemetry. ```bash go run . ``` -------------------------------- ### vmctl Configuration for Different Migration Scenarios Source: https://docs.victoriametrics.com/victoriametrics/vmctl/victoriametrics/index.html These examples show how to configure vm-native-src-addr and vm-native-dst-addr for various migration scenarios between clusters and single instances. Adjust the addresses and paths according to your source and destination setups. ```bash # Migrating from cluster specific tenantID to single --vm-native-src-addr=http://:8481/select/0/prometheus --vm-native-dst-addr=http://:8428 ``` ```bash # Migrating from single to cluster specific tenantID --vm-native-src-addr=http://:8428 --vm-native-dst-addr=http://:8480/insert/0/prometheus ``` ```bash # Migrating single to single --vm-native-src-addr=http://:8428 --vm-native-dst-addr=http://:8428 ``` -------------------------------- ### Install and Start VictoriaMetrics Service (Windows) Source: https://docs.victoriametrics.com/victoriametrics/index.html PowerShell commands to install and start the VictoriaMetrics Windows service after configuring it with WinSW. ```powershell winsw install VictoriaMetrics.xml Get-Service VictoriaMetrics | Start-Service ``` -------------------------------- ### Initialize Go Module for OpenTelemetry Example Source: https://docs.victoriametrics.com/guides/getting-started-with-opentelemetry/index.html Initialize a Go module and download dependencies for the OpenTelemetry example application. ```bash go mod init vm/otel go mod tidy ``` -------------------------------- ### Example VictoriaMetrics Pods Output Source: https://docs.victoriametrics.com/guides/k8s-monitoring-via-vm-cluster/index.html This is an example output showing the expected pods and their status after a successful VictoriaMetrics cluster installation. ```text NAME READY STATUS RESTARTS AGE vmcluster-victoria-metrics-cluster-vminsert-689cbc8f55-95szg 1/1 Running 0 16m vmcluster-victoria-metrics-cluster-vminsert-689cbc8f55-f852l 1/1 Running 0 16m vmcluster-victoria-metrics-cluster-vmselect-977d74cdf-bbgp5 1/1 Running 0 16m vmcluster-victoria-metrics-cluster-vmselect-977d74cdf-vzp6z 1/1 Running 0 16m vmcluster-victoria-metrics-cluster-vmstorage-0 1/1 Running 0 16m vmcluster-victoria-metrics-cluster-vmstorage-1 1/1 Running 0 16m ``` -------------------------------- ### Example Configuration Before Upgrade to 0.5.0 Source: https://docs.victoriametrics.com/helm/victoria-metrics-distributed/index.html Illustrates the configuration structure for vmauthIngestGlobal, vmauthQueryGlobal, and availabilityZones before the refactoring in version 0.5.0. ```yaml vmauthIngestGlobal: spec: extraArgs: discoverBackendIPs: "true" vmauthQueryGlobal: spec: extraArgs: discoverBackendIPs: "true" availabilityZones: - name: zone-eu-1 vmauthIngest: spec: extraArgs: discoverBackendIPs: "true" vmcluster: spec: retentionPeriod: "14" ``` -------------------------------- ### Start vlagent with Remote Write URL Source: https://docs.victoriametrics.com/victorialogs/vlagent/index.html Example command to start vlagent, accepting logs on port 9429 and forwarding them to a VictoriaLogs instance. ```bash /path/to/vlagent-prod -remoteWrite.url=http://victoria-logs-host:9428/insert/native ``` -------------------------------- ### Rename fields with prefix matching Source: https://docs.victoriametrics.com/victorialogs/logsql Renames fields matching a prefix pattern. This example renames all fields starting with 'foo' to fields starting with 'bar'. ```logsql _time:5m | rename foo* as bar* ``` -------------------------------- ### Configure VMAgent with SelectAllByDefault Source: https://docs.victoriametrics.com/operator/security Example configuration for VMAgent, demonstrating the use of `selectAllByDefault: true` to collect metrics from all pods in the namespace. It also shows how to configure remote write endpoints and replica count. ```yaml apiVersion: operator.victoriametrics.com/v1beta1 kind: VMAgent metadata: name: example namespace: default spec: remoteWrite: - url: http://vmsingle-vms-victoria-metrics-k8s-stack.default.svc:8428/api/v1/write replicaCount: 1 selectAllByDefault: true statefulMode: true ``` -------------------------------- ### Copy Fields with Prefix Source: https://docs.victoriametrics.com/victorialogs/logsql/index.html Copies all fields with a specified prefix to fields with another prefix. This example copies all fields starting with 'foo' to fields starting with 'bar'. ```LogSQL _time:5m | copy foo* as bar* ``` -------------------------------- ### Example Split Configuration File (Part 1) Source: https://docs.victoriametrics.com/anomaly-detection/faq/index.html Illustrates the structure of a split configuration file, focusing on the `reader` and `queries` sections. This example shows how `extra_filters` can be defined for a specific region. ```yaml # config file #1, for 1st vmanomaly instance # ... reader: # ... queries: extra_big_query: metricsql_expression_returning_too_many_timeseries extra_filters: # suppose you have a label `region` with values to deterministically define such subsets - '{env="region_name_1"}' # ... ``` -------------------------------- ### Build vmalert Binary for Development Source: https://docs.victoriametrics.com/victoriametrics/vmalert/index.html Run this command from the repository root after installing Go to build the vmalert binary for development purposes. The binary will be placed in the 'bin' folder. ```bash make vmalert ``` -------------------------------- ### Example Alertmanager Service Output Source: https://docs.victoriametrics.com/guides/vmalert-datasource-managed-alerts-grafana This is an example output from the 'kubectl get svc' command, showing the Alertmanager service details. Note the NAME and PORT(S) columns. ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE vmalert-victoria-metrics-alert-alertmanager ClusterIP 10.43.114.243 9093/TCP 68m ``` -------------------------------- ### Example Configuration After Upgrade to 0.5.0 Source: https://docs.victoriametrics.com/helm/victoria-metrics-distributed/index.html Shows the equivalent configuration structure after the refactoring in version 0.5.0, with parameter names changed to reflect the new structure. ```yaml write: global: vmauth: spec: extraArgs: discoverBackendIPs: "true" read: global: vmauth: spec: extraArgs: discoverBackendIPs: "true" availabilityZones: - name: zone-eu-1 write: vmauth: spec: extraArgs: discoverBackendIPs: "true" vmcluster: spec: retentionPeriod: "14" ``` -------------------------------- ### Install Helm Chart Locally (Minikube) Source: https://docs.victoriametrics.com/helm/victoria-metrics-k8s-stack/index.html Install the `victoria-metrics-k8s-stack` chart on Minikube using a dry-run command. This example uses both a custom `values.yaml` and a Minikube-specific `values.minikube.yaml` file. ```bash helm install [RELEASE_NAME] vm/victoria-metrics-k8s-stack -f values.yaml -f values.minikube.yaml -n NAMESPACE --debug --dry-run ``` -------------------------------- ### vmbackupmanager Configuration and Launch Source: https://docs.victoriametrics.com/victoriametrics/vmbackupmanager/index.html Example of how to launch vmbackupmanager with GCS destination, credentials file, and storage configuration. Ensure environment variables are set correctly before execution. ```bash export NODE_IP=192.168.0.10 export VMSTORAGE_ENDPOINT=http://127.0.0.1:8428 ./vmbackupmanager -dst=gs://vmstorage-data/$NODE_IP -credsFilePath=credentials.json -storageDataPath=/vmstorage-data -snapshot.createURL=$VMSTORAGE_ENDPOINT/snapshot/create -licenseFile=/path/to/vm-license ``` -------------------------------- ### Start Minikube Cluster Source: https://docs.victoriametrics.com/helm/victoria-metrics-k8s-stack/index.html Start a Minikube cluster with specific configurations for the container runtime and API server bind addresses. This setup is recommended for local development to avoid potential issues. ```bash minikube start --container-runtime=containerd --extra-config=scheduler.bind-address=0.0.0.0 --extra-config=controller-manager.bind-address=0.0.0.0 --extra-config=etcd.listen-metrics-urls=http://0.0.0.0:2381 ``` -------------------------------- ### Launch vmbackupmanager with GCS Configuration Source: https://docs.victoriametrics.com/victoriametrics/vmbackupmanager Example command to launch vmbackupmanager, specifying the destination bucket, credentials file, storage path, and snapshot creation URL. ```bash export NODE_IP=192.168.0.10 export VMSTORAGE_ENDPOINT=http://127.0.0.1:8428 ./vmbackupmanager -dst=gs://vmstorage-data/$NODE_IP -credsFilePath=credentials.json -storageDataPath=/vmstorage-data -snapshot.createURL=$VMSTORAGE_ENDPOINT/snapshot/create -licenseFile=/path/to/vm-license ``` -------------------------------- ### Get Installed Pods Source: https://docs.victoriametrics.com/helm/victoria-metrics-operator-crds/index.html Retrieves a list of pods associated with the 'vmoc' release across all namespaces. ```bash kubectl get pods -A | grep 'vmoc' ``` -------------------------------- ### vmgateway Help Output Source: https://docs.victoriametrics.com/victoriametrics/vmgateway/index.html This output lists all available configuration flags for vmgateway. Run `./vmgateway -help` to view this. ```text -auth.httpHeader string HTTP header name to look for JWT authorization token (default "Authorization") -auth.jwksEndpoints array JWKS endpoints to fetch keys for JWT tokens signature verification Supports an array of values separated by a comma or specified via multiple flags. Each array item can contain comma inside single-quoted or double-quoted string, {}, [] and () braces. -auth.oidcDiscoveryEndpoints array OpenID Connect discovery endpoints to fetch keys for JWT tokens signature verification Supports an array of values separated by comma or specified via multiple flags. Each array item can contain comma inside single-quoted or double-quoted string, {}, [] and () braces. -auth.publicKeyFiles array Path file with public key to verify JWT token signature Supports an array of values separated by comma or specified via multiple flags. Each array item can contain comma inside single-quoted or double-quoted string, {}, [] and () braces. -auth.publicKeys array Public keys to verify JWT token signature Supports an array of values separated by comma or specified via multiple flags. Each array item can contain comma inside single-quoted or double-quoted string, {}, [] and () braces. -clusterMode enable this for the cluster version -datasource.appendTypePrefix Whether to add type prefix to -datasource.url based on the query type. Set to true if sending different query types to the vmselect URL. -datasource.basicAuth.password string Optional basic auth password for -datasource.url -datasource.basicAuth.passwordFile string Optional path to basic auth password to use for -datasource.url -datasource.basicAuth.username string Optional basic auth username for -datasource.url -datasource.basicAuth.usernameFile string Optional path to basic auth username to use for -datasource.url -datasource.bearerToken string Optional bearer auth token to use for -datasource.url. -datasource.bearerTokenFile string Optional path to bearer token file to use for -datasource.url. -datasource.disableKeepAlive Whether to disable long-lived connections to the datasource. If true, disables HTTP keep-alive and will only use the connection to the server for a single HTTP request. -datasource.disableStepParam Whether to disable adding 'step' param to the issued instant queries. This might be useful when using vmalert with datasources that do not support 'step' param for instant queries, like Google Managed Prometheus. It is not recommended to enable this flag if you use vmalert with VictoriaMetrics. -datasource.headers string Optional HTTP extraHeaders to send with each request to the corresponding -datasource.url. For example, -datasource.headers='My-Auth:foobar' would send 'My-Auth: foobar' HTTP header with every request to the corresponding -datasource.url. Multiple headers must be delimited by '^^': -datasource.headers='header1:value1^^header2:value2' -datasource.maxIdleConnections int Defines the number of idle (keep-alive connections) to each configured datasource. Consider setting this value equal to the value: groups_total * group.concurrency. Too low a value may result in a high number of sockets in TIME_WAIT state. (default 100) -datasource.oauth2.clientID string Optional OAuth2 clientID to use for -datasource.url -datasource.oauth2.clientSecret string Optional OAuth2 clientSecret to use for -datasource.url -datasource.oauth2.clientSecretFile string Optional OAuth2 clientSecretFile to use for -datasource.url -datasource.oauth2.endpointParams string Optional OAuth2 endpoint parameters to use for -datasource.url . The endpoint parameters must be set in JSON format: {"param1":"value1",...,"paramN":"valueN"} -datasource.oauth2.scopes string Optional OAuth2 scopes to use for -datasource.url. Scopes must be delimited by ';' -datasource.oauth2.tokenUrl string Optional OAuth2 tokenURL to use for -datasource.url -datasource.queryStep duration How far a value can fallback to when evaluating queries. For example, if -datasource.queryStep=15s then param "step" with value "15s" will be added to every query. If set to 0, rule's evaluation interval will be used instead. (default 5m0s) -datasource.roundDigits int Adds "round_digits" GET param to datasource requests. In VM "round_digits" limits the number of digits after the decimal point in response values. -datasource.showURL Whether to avoid stripping sensitive information such as auth headers or passwords from URLs in log messages or UI and exported metrics. It is hidden by default, since it can contain sensitive info such as auth key -datasource.tlsCAFile string ``` -------------------------------- ### Minimalistic vmanomaly Configuration Example Source: https://docs.victoriametrics.com/anomaly-detection/components/index.html This example demonstrates a full, minimalistic configuration for vmanomaly, showcasing many-to-many component setup. It includes settings for workers, anomaly score thresholds, state restoration, and model retention. ```yaml settings: n_workers: 4 # number of workers to run models in parallel anomaly_score_outside_data_range: 5.0 # default anomaly score for anomalies outside expected data range restore_state: True # restore state from previous run, if available retention: # how long to keep stale models on disk/in memory ttl: "1d" # time-to-live duration, if the model was not used for inference within this duration, it will be considered stale check_interval: "1h" # how often to check for stale models and remove them # how and when to run the models is defined by schedulers # https://docs.victoriametrics.com/anomaly-detection/components/scheduler/ schedulers: periodic_online: # alias class: 'periodic' # scheduler class infer_every: "30s" # how often to produce anomaly scores for new data scatter_infer_jobs: true # distribute infer jobs evenly across the infer interval to reduce synchronized bursts fit_every: "365d" # how often to re-fit the models, for online models used effectively once, then they are updated with new data and won't require re-fit fit_window: "3d" # how much historical data to use for fit stage start_from: "00:00" # start from specified time, i.e. 00:00 given timezone and do daily fits as `fit_every` is 1 day tz: "Europe/Kyiv" # timezone to use for start_from periodic_offline_1w: class: 'periodic' infer_every: "15m" scatter_infer_jobs: true fit_every: "24h" fit_window: "14d" # if no start_from is specified, jobs will start immediately after service starts # what model types and with what hyperparams to run on your data # https://docs.victoriametrics.com/anomaly-detection/components/models/ models: zscore: class: 'zscore_online' # model class z_threshold: 3.5 decay: 0.99 # weight for data points value should be in (0, 1], 1 means to give equal weight to all data provide_series: ['anomaly_score', 'y', 'yhat', 'yhat_upper'] # what series to produce as output of the model queries: ['host_network_receive_errors'] # what queries to run particular model on schedulers: ['periodic_online'] # will be fit once, used for infer every 30s min_dev_from_expected: 0.0 # turned off. if |y - yhat| < min_dev_from_expected, anomaly score will be 0 detection_direction: 'above_expected' # detect anomalies only when y > yhat, "peaks" clip_predictions: True # clip predictions to expected data range, i.e. [0, inf] for this query `host_network_receive_errors prophet_weekly: # we can set up alias for model class: 'prophet' provide_series: ['anomaly_score', 'y', 'yhat', 'yhat_lower', 'yhat_upper'] queries: ['cpu_seconds_total'] schedulers: ['periodic_offline_1w'] # will be attached to 1-week scheduler, re-fit every 24h and infer every 15m min_dev_from_expected: [0.01, 0.01] # minimum deviation from expected value to be even considered as anomaly anomaly_score_outside_data_range: 1.5 # override default anomaly score outside expected data range detection_direction: 'above_expected' clip_predictions: True # clip predictions to expected data range, i.e. [0, inf] for this query `cpu_seconds_total` args: # model-specific arguments interval_width: 0.98 yearly_seasonality: False # disable yearly seasonality, since we have only 7 days of data ``` -------------------------------- ### Configure vlogscli Datasource URL Source: https://docs.victoriametrics.com/victorialogs/querying/vlogscli/index.html Example of how to start vlogscli and specify a custom datasource URL for querying VictoriaLogs. ```bash ./vlogscli -datasource.url='https://victoria-logs.some-domain.com/select/logsql/query' ``` -------------------------------- ### vmanomaly Startup: Model and Data Directory Setup Source: https://docs.victoriametrics.com/anomaly-detection/components/monitoring/index.html Logs concerning the setup of directories for storing anomaly detection models and data. It shows whether environment variables are used or if storage defaults to in-memory. ```text Using ENV MODEL_DUMP_DIR=`{{model_dump_dir}}` to store anomaly detection models. ``` ```text ENV MODEL_DUMP_DIR is not set. Models will be kept in RAM between consecutive `fit` calls. ``` ```text Using ENV DATA_DUMP_DIR=`{{data_dump_dir}}` to store anomaly detection data. ``` ```text ENV DATA_DUMP_DIR is not set. Models' training data will be stored in RAM. ``` -------------------------------- ### vmagent Optimized Command-Line Example Source: https://docs.victoriametrics.com/victoriametrics/vmagent/index.html This example demonstrates running vmagent with several flags to optimize CPU and RAM usage. It includes disabling compression and keep-alive, dropping original labels, setting memory limits, and adjusting garbage collection. ```bash GOGC=100 GOMAXPROCS=1 ./vmagent -promscrape.disableCompression -promscrape.dropOriginalLabels -promscrape.noStaleMarkers -memory.allowedBytes=1GiB -promscrape.disableKeepAlive ... ``` -------------------------------- ### VMPodScrape Example: Discover Pods in All Namespaces Source: https://docs.victoriametrics.com/operator/resources/vmpodscrape/index.html This example demonstrates how to configure a VMPodScrape resource to discover pods across all namespaces by setting `namespaceSelector.any` to `true`. This is useful for broad monitoring setups. ```yaml apiVersion: operator.victoriametrics.com/v1beta1 kind: VMPodScrape metadata: name: example spec: namespaceSelector: any: true ``` -------------------------------- ### Metrics Formatting: Example Output Source: https://docs.victoriametrics.com/anomaly-detection/components/writer Illustrates the resulting metric format when both basic and custom label configurations are applied, including inherited labels like cpu, device, and instance. ```text {__name__="PREFIX1_anomaly_score", for="PREFIX2_query_name_1", custom_label_1="label_name_1", custom_label_2="label_name_2", cpu=1, device="eth0", instance="node-exporter:9100"} {__name__="PREFIX1_yhat_lower", for="PREFIX2_query_name_1", custom_label_1="label_name_1", custom_label_2="label_name_2", cpu=1, device="eth0", instance="node-exporter:9100"} {__name__="PREFIX1_anomaly_score", for="PREFIX2_query_name_2", custom_label_1="label_name_1", custom_label_2="label_name_2", cpu=1, device="eth0", instance="node-exporter:9100"} {__name__="PREFIX1_yhat_lower", for="PREFIX2_query_name_2", custom_label_1="label_name_1", custom_label_2="label_name_2", cpu=1, device="eth0", instance="node-exporter:9100"} ``` -------------------------------- ### Remove prefix from fields Source: https://docs.victoriametrics.com/victorialogs/logsql Removes a common prefix from field names. This example removes the 'foo' prefix from all fields that start with 'foo'. ```logsql _time:5m | rename foo* as * ``` -------------------------------- ### vmanomaly Configuration Example Source: https://docs.victoriametrics.com/anomaly-detection/components A minimalistic full configuration example for vmanomaly, demonstrating many-to-many component configuration. This example covers settings, schedulers, models, and their parameters. ```yaml settings: n_workers: 4 anomaly_score_outside_data_range: 5.0 restore_state: True retention: ttl: "1d" check_interval: "1h" schedulers: periodic_online: class: 'periodic' infer_every: "30s" scatter_infer_jobs: true fit_every: "365d" fit_window: "3d" start_from: "00:00" tz: "Europe/Kyiv" periodic_offline_1w: class: 'periodic' infer_every: "15m" scatter_infer_jobs: true fit_every: "24h" fit_window: "14d" models: zscore: class: 'zscore_online' z_threshold: 3.5 decay: 0.99 provide_series: ['anomaly_score', 'y', 'yhat', 'yhat_upper'] queries: ['host_network_receive_errors'] schedulers: ['periodic_online'] min_dev_from_expected: 0.0 detection_direction: 'above_expected' clip_predictions: True prophet_weekly: class: 'prophet' provide_series: ['anomaly_score', 'y', 'yhat', 'yhat_lower', 'yhat_upper'] queries: ['cpu_seconds_total'] schedulers: ['periodic_offline_1w'] min_dev_from_expected: [0.01, 0.01] anomaly_score_outside_data_range: 1.5 detection_direction: 'above_expected' clip_predictions: True args: interval_width: 0.98 yearly_seasonality: False ``` -------------------------------- ### Example Split Configuration File (Part 2) Source: https://docs.victoriametrics.com/anomaly-detection/faq/index.html Presents another example of a split configuration file, similar to the first but demonstrating a different value for the `extra_filters` label, suitable for a second vmanomaly instance. ```yaml # config file #2, for 2nd vmanomaly instance # ... reader: # ... queries: extra_big_query: metricsql_expression_returning_too_many_timeseries extra_filters: # suppose you have a label `region` with values to deterministically define such subsets - '{region="region_name_2"}' # ... ``` -------------------------------- ### Start vmestimator Storage Nodes Source: https://docs.victoriametrics.com/victoriametrics/vmestimator/index.html Configure and run vmestimator instances as storage nodes in a clustered setup. Ensure each has a unique httpListenAddr. ```bash vmestimator -config=streams.yaml -httpListenAddr=:8491 -cardinalityMetrics.exposeAt=/cardinality/metrics vmestimator -config=streams.yaml -httpListenAddr=:8492 -cardinalityMetrics.exposeAt=/cardinality/metrics vmestimator -config=streams.yaml -httpListenAddr=:8493 -cardinalityMetrics.exposeAt=/cardinality/metrics ``` -------------------------------- ### List Installed Pods Source: https://docs.victoriametrics.com/helm/victoria-metrics-k8s-stack/index.html Get a list of all pods in all namespaces that contain 'vmks' in their name. This helps verify that the VictoriaMetrics stack components are running. ```bash kubectl get pods -A | grep 'vmks' ``` -------------------------------- ### Install helm-docs Source: https://docs.victoriametrics.com/helm/requirements Commands to download, extract, and install `helm-docs` version 1.5.0. It places the binary in `/usr/local/bin/` and makes it executable. ```bash HELM_DOCS_VERSION=1.5.0 HELM_DOCS_PACKAGE=helm-docs_``$HELM_DOCS_VERSION``_linux_x86_64.tar.gz cd /tmp wget https://github.com/norwoodj/helm-docs/releases/download/v$HELM_DOCS_VERSION/$HELM_DOCS_PACKAGE tar xzvf $HELM_DOCS_PACKAGE sudo mv helm-docs /usr/local/bin/ sudo chmod +rx /usr/local/bin/helm-docs helm-docs --version ``` -------------------------------- ### Alertmanager Configuration Example for VictoriaMetrics Cloud Source: https://docs.victoriametrics.com/victoriametrics-cloud/alertmanager-setup-for-deployment This example demonstrates a typical Alertmanager configuration for VictoriaMetrics Cloud, specifying routing rules and receiver configurations for Slack notifications. It includes details on how to format alerts and define actions. ```yaml route: receiver: slack-infra repeat_interval: 1m group_interval: 30s routes: - matchers: - team = team-1 receiver: dev-team-1 continue: true - matchers: - team = team-2 receiver: dev-team-2 continue: true receivers: - name: slack-infra slack_configs: - api_url: https://hooks.slack.com/services/valid-url channel: infra title: |- [{{ .Status | toUpper -}} {{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{- end -}} ] {{ if ne .Status "firing" -}} :lgtm: {{- else if eq .CommonLabels.severity "critical" -}} :fire: {{- else if eq .CommonLabels.severity "warning" -}} :warning: {{- else if eq .CommonLabels.severity "info" -}} :information_source: {{- else -}} :question: {{- end }} text: | {{ range .Alerts }} {{- if .Annotations.summary }} Summary: {{ .Annotations.summary }} {{- end }} {{- if .Annotations.description }} Description: {{ .Annotations.description }} {{- end }} {{- end }} actions: - type: button text: 'Query :mag:' url: '{{ (index .Alerts 0).GeneratorURL }}' - type: button text: 'Silence :no_bell:' url: '{{ template "__silenceURL" . }}' - name: dev-team-1 slack_configs: - api_url: https://hooks.slack.com/services/valid-url channel: dev-alerts - name: dev-team-2 slack_configs: - api_url: https://hooks.slack.com/services/valid-url channel: dev-alerts ``` -------------------------------- ### Example Output Metrics with Formatting Source: https://docs.victoriametrics.com/anomaly-detection/components/writer/index.html Illustrates the structure of output metrics after applying the specified `metric_format` configuration, including base names, query labels, custom labels, and inherited input labels. ```text {__name__="PREFIX1_anomaly_score", for="PREFIX2_query_name_1", custom_label_1="label_name_1", custom_label_2="label_name_2", cpu=1, device="eth0", instance="node-exporter:9100"} {__name__="PREFIX1_yhat_lower", for="PREFIX2_query_name_1", custom_label_1="label_name_1", custom_label_2="label_name_2", cpu=1, device="eth0", instance="node-exporter:9100"} {__name__="PREFIX1_anomaly_score", for="PREFIX2_query_name_2", custom_label_1="label_name_1", custom_label_2="label_name_2", cpu=1, device="eth0", instance="node-exporter:9100"} {__name__="PREFIX1_yhat_lower", for="PREFIX2_query_name_2", custom_label_1="label_name_1", custom_label_2="label_name_2", cpu=1, device="eth0", instance="node-exporter:9100"} ``` -------------------------------- ### Build vmbackup Binary (Production) Source: https://docs.victoriametrics.com/victoriametrics/vmbackup/index.html Use this command to build the production-ready vmbackup binary. Docker must be installed. ```bash make vmbackup-prod ``` -------------------------------- ### Example Alerting Rules in Prometheus Format Source: https://docs.victoriametrics.com/victoriametrics-cloud/alertmanager-setup-for-deployment/index.html An example of alerting rules formatted according to the Prometheus alerting rules definition. This format is used for defining alerts that trigger based on specific Prometheus query expressions. ```yaml groups: - name: examples concurrency: 2 interval: 10s rules: - alert: never-firing expr: foobar > 0 for: 30s labels: severity: warning annotations: summary: empty result rule - alert: always-firing expr: vector(1) > 0 for: 30s labels: severity: critical annotations: summary: "rule must be always at firing state" ``` -------------------------------- ### Build vlagent Locally Source: https://docs.victoriametrics.com/victorialogs/vlagent/index.html Build the vlagent binary using the make command. Requires Go to be installed. ```bash make vlagent ``` -------------------------------- ### Get unique field values Source: https://docs.victoriametrics.com/victorialogs/logsql-examples Retrieves distinct values or sets of values for specified fields within a given time range. ```LogsQL _time:5m | uniq by (ip) _time:5m | uniq by (host, path) ``` -------------------------------- ### vmanomaly Startup: Scheduler and Service Initialization Source: https://docs.victoriametrics.com/anomaly-detection/components/monitoring/index.html Logs detailing the initialization of schedulers and services within vmanomaly. It includes warnings for unconfigured schedulers and a list of active schedulers upon successful setup. ```text Scheduler {{scheduler_alias}} wrapped and initialized with {{N}} model spec(s). ``` ```text No model spec(s) found for scheduler `{{scheduler_alias}}`, skipping setting it up. ``` ```text Active schedulers: {{list_of_schedulers}}. ``` -------------------------------- ### Count all metrics with PromQL Source: https://docs.victoriametrics.com/victoriametrics/vmestimator Use this PromQL query to get the global cardinality of all metrics. This approach is suitable for small setups and may not scale well. ```promql count({__name__=~".*"}) ``` -------------------------------- ### Get Pods by Name Source: https://docs.victoriametrics.com/helm/victoria-metrics-single/index.html Retrieves a list of all pods across all namespaces that contain 'vms' in their name. This command helps to check the status of VictoriaMetrics pods after installation. ```bash kubectl get pods -A | grep 'vms' ``` -------------------------------- ### Build vmrestore Binary (Development) Source: https://docs.victoriametrics.com/victoriametrics/vmrestore/index.html Builds the vmrestore binary for development purposes. Requires Go to be installed. ```bash make vmrestore ``` -------------------------------- ### VLogs CRD - Example with Storage and Resources Source: https://docs.victoriametrics.com/operator/resources/vlogs/index.html A comprehensive example of a VLogs CRD, including storage configuration with access modes and requested storage size, as well as detailed resource requests and limits for CPU and memory. This demonstrates a complete deployment setup. ```yaml apiVersion: operator.victoriametrics.com/v1beta1 kind: VLogs metadata: name: example spec: retentionPeriod: "12" removePvcAfterDelete: true storage: accessModes: - ReadWriteOnce resources: requests: storage: 50Gi resources: requests: memory: 500Mi cpu: 500m limits: memory: 10Gi cpu: 5 ``` -------------------------------- ### GCE Service Discovery Configuration Example Source: https://docs.victoriametrics.com/victoriametrics/sd_configs/index.html Example configuration for discovering GCE instances as scrape targets. Customize 'project', 'zone', 'filter', and 'port' as needed. ```yaml scrape_configs: - job_name: gce gce_sd_configs: # project is an optional GCE project where targets must be discovered. # By default, the local project is used. # - project: "..." # zone is an optional zone where targets must be discovered. # By default, the local zone is used. # If zone equals to '*', then targets in all the zones for the given project are discovered. # The zone may contain a list of zones: zone["us-east1-a", "us-east1-b"] # # zone: "..." # filter is an optional filter for the instance list. # See https://cloud.google.com/compute/docs/reference/latest/instances/list # # filter: "..." # port is an optional port to scrape metrics from. # By default, port 80 is used. # # port: ... # tag_separator is an optional separator for tags in `__meta_gce_tags` label. # By default, "," is used. # # tag_separator: "..." ``` -------------------------------- ### Build vmbackup Binary (Development) Source: https://docs.victoriametrics.com/victoriametrics/vmbackup/index.html Use this command to build the vmbackup binary for development purposes. Ensure Go is installed. ```bash make vmbackup ``` -------------------------------- ### Filtering Tenants with Regular Expressions Source: https://docs.victoriametrics.com/victoriametrics/cluster-victoriametrics/index.html Shows how to use regular expressions in label selectors to filter tenants based on patterns. This example selects accountIDs starting with '4'. ```promql up{vm_account_id=~"4.*"} ``` -------------------------------- ### Delete fields with a common prefix Source: https://docs.victoriametrics.com/victorialogs/logsql/index.html The `delete` pipe supports wildcard matching to remove fields starting with a specific prefix. This example deletes all fields beginning with 'foo'. ```LogQL _time:5m | delete foo* ```