2022-01-21 11:05:58 +01:00
|
|
|
---
|
|
|
|
sort: 2
|
|
|
|
---
|
|
|
|
|
|
|
|
# Additional Scrape Configuration
|
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
AdditionalScrapeConfigs is an additional way to add scrape targets in VMAgent CRD.
|
|
|
|
There are two options for adding targets into VMAgent: inline configuration into CRD or defining it as a Kubernetes Secret.
|
2022-01-21 11:05:58 +01:00
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
No validation happens during the creation of configuration. However, you must validate job specs, and it must follow job spec configuration.
|
2022-08-06 23:04:31 +02:00
|
|
|
Please check [scrape_configs documentation](https://docs.victoriametrics.com/sd_configs.html#scrape_configs) as references.
|
2022-01-21 11:05:58 +01:00
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
## Inline Additional Scrape Configuration in VMAgent CRD
|
|
|
|
|
|
|
|
You need to add scrape configuration directly to the vmagent spec.inlineScrapeConfig. It is raw text in YAML format.
|
|
|
|
See example below
|
2022-01-21 11:05:58 +01:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
cat <<EOF | kubectl apply -f -
|
|
|
|
apiVersion: operator.victoriametrics.com/v1beta1
|
|
|
|
kind: VMAgent
|
|
|
|
metadata:
|
|
|
|
name: example-vmagent
|
|
|
|
spec:
|
|
|
|
serviceScrapeSelector: {}
|
|
|
|
replicas: 1
|
|
|
|
serviceAccountName: vmagent
|
|
|
|
inlineScrapeConfig: |
|
|
|
|
- job_name: "prometheus"
|
|
|
|
static_configs:
|
|
|
|
- targets: ["localhost:9090"]
|
|
|
|
remoteWrite:
|
|
|
|
- url: "http://vmagent-example-vmsingle.default.svc:8429/api/v1/write"
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
**Note**: Do not use passwords and tokens with inlineScrapeConfig use Secret instead of
|
|
|
|
|
2022-01-21 11:05:58 +01:00
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
## Define Additional Scrape Configuration as a Kubernetes Secret
|
2022-01-21 11:05:58 +01:00
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
You need to define Kubernetes Secret with a key.
|
2022-01-21 11:05:58 +01:00
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
The key is `prometheus-additional.yaml` in the example below
|
2022-01-21 11:05:58 +01:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
cat <<EOF | kubectl apply -f -
|
|
|
|
apiVersion: v1
|
|
|
|
kind: Secret
|
|
|
|
metadata:
|
|
|
|
name: additional-scrape-configs
|
|
|
|
stringData:
|
|
|
|
prometheus-additional.yaml: |
|
|
|
|
- job_name: "prometheus"
|
|
|
|
static_configs:
|
|
|
|
- targets: ["localhost:9090"]
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
After that, you need to specify the secret's name and key in VMAgent CRD in `additionalScrapeConfigs` section
|
2022-01-21 11:05:58 +01:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
cat <<EOF | kubectl apply -f -
|
|
|
|
apiVersion: operator.victoriametrics.com/v1beta1
|
|
|
|
kind: VMAgent
|
|
|
|
metadata:
|
|
|
|
name: example-vmagent
|
|
|
|
spec:
|
|
|
|
serviceScrapeSelector: {}
|
|
|
|
replicas: 1
|
|
|
|
serviceAccountName: vmagent
|
|
|
|
additionalScrapeConfigs:
|
|
|
|
name: additional-scrape-configs
|
|
|
|
key: prometheus-additional.yaml
|
|
|
|
remoteWrite:
|
|
|
|
- url: "http://vmagent-example-vmsingle.default.svc:8429/api/v1/write"
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
2022-07-05 11:06:23 +02:00
|
|
|
**Note**: You can specify only one Secret in the VMAgent CRD configuration so use it for all additional scrape configurations.
|
2022-01-21 11:05:58 +01:00
|
|
|
|