I am trying to apply kubernetes to my minikube cluster for the first time. I have limited experience with cluster management and have never worked with prometheus before so I apologize for noob errors.
I run the following commands:
docker build -t my-prometheus .
docker run -p 9090:9090 my-prometheus
here is my yaml:
global:
scrape_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'kubernetes-apiservers'
scheme: http
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
kubernetes_sd_configs:
- role: endpoints
- api_server: localhost:30000
I ran this through YAMLlint and got that it was valid. However I get the following error when I run the second docker command:
level=error ts=2018-09-18T21:49:34.365671918Z caller=main.go:617 err="error
loading config from \"/etc/prometheus/prometheus.yml\": couldn't load
configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing
YAML file /etc/prometheus/prometheus.yml: role missing (one of: pod,
service, endpoints, node)"
However, you can see that I have specified my - role: endpoints
in my kubernetes_sd_configs
.
Can anyone help me on this
kubernetes_sd_configs
is a list of configs, styled as block sequence in YAML terms.
Now, your list of configs looks like this:
- role: endpoints
- api_server: localhost:3000
So you're defining two configs, and only the first one of them has a role. This is why you get the error. Most probably, you want to create only one config with role
and api_server
configured. Drop the second -
so that the api_server
belongs to the first config:
- role: endpoints
api_server: localhost:3000