Skip to content

Database monitoring

The same script that adds the nodes to zabbix should also be able to on a seprate task add the database to zabbix to be monitored and apply a database template to it. There should be an existing one that we can use in the server image.

Should look something like this in roles/zabbix/tasks/main.yml:

- name: Run database monitoring config job
  k8s:
    state: "{{ state }}"
    definition:
      apiVersion: batch/v1
      kind: Job
      metadata:
        labels:
          app: zabbix
          tier: job
          release: "{{ release }}"
          domain: "{{ domain }}"
        name: zabbix-database-monitoring-job
        namespace: "{{ instance }}"
      spec:
        template:
          metadata:
            name: cluster-config
          spec:
            containers:
              - name: cluster-config-job
                image: "{{ cluster_config_job_image }}:{{ cluster_config_job_image_tag }}"
                args:
                  - "-user"
                  - "{{ zabbix_frontend_user }}"
                  - "-passwd"
                  - "{{ zabbix_frontend_passwd }}"
                  - "-database"
                  - "{{ database_config }}"
            restartPolicy: OnFailure
        backoffLimit: 4
  when:
    - database_monitoring
    - server_deployment.resources[0] is not undefined
    - server_deployment.resources[0].status.availableReplicas
Edited by Tyler French