ho to enable the http_requests_total metric in a Prometheus alert rule

89 views Asked by At

I need to raise custom alert on the basis of the CRUD operation, as I got some suggestion on using The http_requests_total and data_install_state metrics are intended for use in the alert expression, but they are not present in the current metric list. Are there alternative metrics available for achieving the same operation?

The operation involves making an HTTP request to an API at https://localhost:/ and, upon receiving a 200 response, iterating over conditions based on response.json().

Is there a way to implement this operation without these specific metrics, or are there other metrics that can be used in a similar manner?

alert.yaml

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  labels:
    prometheus: {{ .Values.labels }}
    role: {{ .Values.role }}
  name: {{ .Values.name }}
  namespace: {{ .Values.namespace }}

spec:
  groups:
    - name: test
      rules:
        - alert: test
          expr: <Need to be added here>
          for: 15m
          labels:
            severity: warning
            category: Error
            alertcode: EHL_SNI_001
          annotations:
            description: Test for 15 min.
            summary: Test for 15min.

please help me on this.

Tried:

expr: | http_requests_total{job="my_curl_job", status_code="200", method="GET", uri="/v1/site/status/overview"} == 1 and data_install_state{job="my_curl_job", install_state="Complete"} == 1 and time() - http_requests_total{job="my_curl_job", status_code="200", method="GET", uri="/v1/site/status/overview"} > 900

expected:

http_requests_total and data_install_state to be present and throw alert with warning message

0

There are 0 answers