aide-family / moon

prometheus unified rules and alarms management platform
https://aide-family.github.io/i18n/zh/
MIT License
137 stars 47 forks source link

适配Loki数据源 #120

Open aide-cloud opened 5 months ago

aide-cloud commented 5 months ago

loki规则如下, 规则与prometheus一样,适配数据源完成expr转alert事件

groups:
  - name: should_fire
    rules:
      - alert: HighPercentageError
        expr: |
          sum(rate({app="foo", env="production"} |= "error" [5m])) by (job)
            /
          sum(rate({app="foo", env="production"}[5m])) by (job)
            > 0.05
        for: 10m
        labels:
            severity: page
        annotations:
            summary: High request latency
  - name: credentials_leak
    rules: 
      - alert: http-credentials-leaked
        annotations: 
          message: "{{ $labels.job }} is leaking http basic auth credentials."
        expr: 'sum by (cluster, job, pod) (count_over_time({namespace="prod"} |~ "http(s?)://(\\w+):(\\w+)@" [5m]) > 0)'
        for: 10m
        labels: 
          severity: critical