<p>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. </p>

<p>I run the following commands:</p>

<pre><code>docker build -t my-prometheus .
docker run -p 9090:9090 my-prometheus
</code></pre>

<p>here is my yaml:</p>

<pre><code>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
</code></pre>

<p>I ran this through YAMLlint and got that it was valid. However I get the following error when I run the second docker command:</p>

<pre><code>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)"
</code></pre>

<p>However, you can see that I have specified my <code>- role: endpoints</code> in my <code>kubernetes_sd_configs</code>.</p>

<p>Can anyone help me on this</p>

<p><code>kubernetes_sd_configs</code> is a list of configs, styled as block sequence in YAML terms.</p>

<p>Now, your list of configs looks like this:</p>

<pre><code>- role: endpoints
- api_server: localhost:3000
</code></pre>

<p>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 <code>role</code> and <code>api_server</code> configured. Drop the second <code>-</code> so that the <code>api_server</code> belongs to the first config:</p>

<pre><code>- role: endpoints
  api_server: localhost:3000
</code></pre>
