Can someone help me where to define these values - alertmanager.yml, serverFiles, apiVersion, kind,

1,158 views
Skip to first unread message

M McGuinness

unread,
Mar 8, 2018, 10:35:33 AM3/8/18
to Prometheus Users

Hi 

Could someone please help, I am trying to use the config file below and run the following command but its telling me some of the fields are unknown. Could you please help me by letting me know where I should define them or how to tell Prometheus about them?

./promtool check config config-map.yaml

Checking config-map.yaml

  FAILED: parsing YAML file config-map.yaml: unknown fields in config: alertmanager.yml, serverFiles, apiVersion, kind, metadata, data, alertmanagerFiles




apiVersion: v1

kind: ConfigMap

metadata:

name: prometheus-server-conf

labels:

name: prometheus-server-conf

namespace: monitoring

data:

alertmanagerFiles:

alertmanager.yml: |-

global:

# slack_api_url: ''

resolve_timeout: 20s

 

receivers:

- name: default-receiver

# slack_configs:

# - channel: '@you'

# send_resolved: true

- name: 'webhook'

webhook_configs:

- send_resolved: true

url: ''

  

route:

group_wait: 10s

group_interval: 5m

receiver: webhook

repeat_interval: 3h

  

## Prometheus server ConfigMap entries

##

serverFiles: 

rules: ""

alerts: |-

# host rules

ALERT high_node_load

IF node_load1 > 20

FOR 10s

LABELS { severity = "critical" }

ANNOTATIONS {

# summary defines the status if the condition is met

summary = "Node usage exceeded threshold",

# description reports the situtation of event

description = "Instance {{ $labels.instance }}, Job {{ $labels.job }}, Node load {{ $value }}",

}



Thanks in advance for your help!!

Martin Chodúr

unread,
Mar 9, 2018, 12:18:42 AM3/9/18
to Prometheus Users
Hi,
The problem is you that you pass whole configmap definition to the promtool.

Promtool does not know the kubernetes manifest specific fields defining the configmap.

You should paste content of the `alertmanager.yml:` field into a separate file and than run promtool check on this file.

Still your error does not mean your configuration is incorrect you just run the syntax check wrong way but i think the empty url in webhook config of alertmanager could cause problems.

You shoud mount this configmap into the alermanager container and specify alermanager cmd flag to tell it it shoud use this config file.

Hope this helps
Martin

M McGuinness

unread,
Mar 9, 2018, 4:56:00 AM3/9/18
to Prometheus Users
Hi Martin

Thanks so much for getting back to me. I did put the valid web hook URL into the config-map file and ran the following command and it is still giving me a similar error - 

./kubectl create -f ./config-map.yaml -n monitoring

error: error validating "./config-map.yaml": error validating data: [ValidationError(ConfigMap): unknown field "alertmanager.yml" in io.k8s.api.core.v1.ConfigMap, ValidationError(ConfigMap): unknown field "serverFiles" in io.k8s.api.core.v1.ConfigMap]; if you choose to ignore these errors, turn validation off with --validate=false


Could you please guide me on how I would mount this config map into the alert manager container and specify alert manager cmd flag? How do I check if I have an alert manager container?


Many thanks in advance for your help!

Mary-Jo

Martin Chodúr

unread,
Mar 9, 2018, 4:13:43 PM3/9/18
to Prometheus Users
Ok there is more to be aware of..

First thing, you'll probably want to have separate configmaps for Prometheus and Alertmanager since those are separate applications and you will have separate deployments for each of them and this would bring unnecessary files to container.

The second thing is that you have invalid format of configmap. I'd suggest to look closely on the Kubernetes documentation on configmaps which is full of examples to get better glimpse how it should look like.

the valid format would be
Alertmanager config: https://gist.github.com/FUSAKLA/6caf398924a9acc64990ad6d26dc0602
Prometheus rules and alerts: https://gist.github.com/FUSAKLA/085c57645c45ddb213dc09bfa9552d15

I checked the configuration using `promtool` and `amtool` and both are ok.

(Be aware of incompatible alerts and rules format change between Prometheus 1.x.x and new versions 2.x.x )

Next step would be mounting those files from configmaps into the containers of Prometheus and Alertmanager and setting command line flags for config files to use them.
This is also showed in the above linked kubernetes documentation in section `Populate a Volume with data stored in a ConfigMap`

But the most important thing.. those are pretty basic steps towards building own solution how to use Prometheus in Kubernetes.
You should consider projects as prometheus-operator, prometheus helm chart or kube-prometheus to avoid developing something that someone else already did :)

Hope this helps!
Martin


Dne pátek 9. března 2018 10:56:00 UTC+1 M McGuinness napsal(a):

M McGuinness

unread,
Mar 12, 2018, 9:45:12 AM3/12/18
to Prometheus Users
Hi Martin

Thanks for getting back to me again, I tried to follow the documentation you pointed me to - Populate a Volume with data stored in a ConfigMap. I copied the contents of the two files you gave me and added the alertmanager_conf under the volumes section in the deployment file:

apiVersion: extensions/v1beta1

kind: Deployment

metadata:

  name: prometheus-deployment

  namespace: monitoring

spec:

  replicas: 1

  template:

    metadata:

      labels:

        app: prometheus-server

    spec:

      containers:

        - name: prometheus

          image: prom/prometheus:v2.1.0

          args:

            - "--config.file=/etc/prometheus/prometheus.yml"

            - "--storage.tsdb.path=/prometheus/"

          ports:

            - containerPort: 9090

          volumeMounts:

            - name: prometheus-config-volume

              mountPath: /etc/prometheus/

            - name: prometheus-storage-volume

              mountPath: /prometheus/

      volumes:

        - name: prometheus-config-volume

          configMap:

            defaultMode: 420

            name: prometheus-server-conf

            name: alertmanager-conf

          


        - name: prometheus-storage-volume

          emptyDir: {}



Is this correct? Do I have to create the deployment again after this and do I add the prometheus-rules-config.yaml file under the volumes section too?

I can't seem to find the command flags to tell it how to use the config files either. Could you please help again if you don't mind?


Many thanks in advance!

Reply all
Reply to author
Forward
0 new messages