0

I've been having difficulty adding the --web.enable-lifecycle flag to prometheus, to enable the lifecycle api.

I have this working locally with docker compose, like so:

  prometheus:
    image: prom/prometheus
    volumes:
      - ./tmp/prometheus:/prometheus
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
      - ./prometheus/targets:/etc/prometheus/targets
    networks:
      - localprom
    ports:
      - 9090:9090
    command:
      - --web.enable-lifecycle
      - --config.file=/etc/prometheus/prometheus.yml

But Azure's YAML format for creating/updating container instances is a little different than docker. Here is my YAML file:

apiVersion: 2021-10-01
location: useast
name: my-prometheus-container-instances
tags: { environment: development }
type: Microsoft.ContainerInstance/containerGroups

properties:
  containers:
    - name: prometheus
      properties:
        image: prom/prometheus:v2.45.6
        command:
          - /bin/prometheus
          - --config.file=/etc/prometheus/prometheus.yml
          - --web.enable-lifecycle
        resources:
          requests:
            cpu: 1
            memoryInGb: 1.5
        ports:
          - port: 9090
        volumeMounts:
          - name: prometheus-fileshare-volume
            mountPath: /etc/prometheus/

  subnetIds:
    - id: MY_SUBNET_ID

  osType: Linux
  volumes:
    - name: prometheus-fileshare-volume
      azureFile:
        shareName: prometheus-fileshare
        readOnly: true
        storageAccountName: prometheus-storage-account
        storageAccountKey: MY_ACCESS_KEY

  RestartPolicy: OnFailure
  ipAddress:
    type: Private
    ports:
      - protocol: tcp
        port: 9090

Note that the Azure YAML file requires - /bin/prometheus in the command array, while docker does not. Without this, prometheus will not start after deploying. I've also confirmed that the --config.file command is working, wondering if there is something else that may be stopping me from enabling the lifecycle API after deploying to Azure.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.