Help with alert

using docker to set loki 2.4.1, can get log record from promtail. but can not sent any alert afte I set rule. and check my alertmanager no any information from loki, is there any wrong in my config file? thanks
docker-compose content with loki

  loki:
    image: grafana/loki:2.4.1
    volumes:
      - ./config/loki/rules:/etc/loki/rules
      - ./config/loki/local-config.yaml:/etc/loki/local-config.yaml
      - ./data/loki_data:/loki
    ports:
      - "3100:3100"
    command: -config.file=/etc/loki/local-config.yaml -log.level=debug
    networks:
      - back-tier

/etc/loki/local-config.yaml

auth_enabled: false

server:
  http_listen_port: 3100

common:
  path_prefix: /loki
  storage:
    filesystem:
      chunks_directory: /loki/chunks
      rules_directory: /loki/rules
  replication_factor: 1
  ring:
    instance_addr: 127.0.0.1
    kvstore:
      store: inmemory

schema_config:
  configs:
    - from: 2020-10-24
      store: boltdb-shipper
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 24h

ruler:
  alertmanager_url: http://alertmanager:9093
  storage:
    type: local
    local:
      directory: /tmp/rules
  rule_path: /etc/loki/rules
  ring:
    kvstore:
      store: inmemory
  enable_api: true
  enable_alertmanager_v2: true

/etc/loki/rules/energy_upload.yml

  - name: energy_upload
    rules:
      - alert: energy_upload
        annotations:
          message: "检查防火墙能耗上传数据包失败,检查能耗软件是否正常工作."
        expr: 'count_over_time({job="enerygy-consume"}[1m]) < 1'
        for: 5m
        labels:
          severity: critical

Hi @tbs575

Do you see any errors in the logs? I’d like to first rule out a networking error.

using docker logs -f xxxx to check logs, so many records in log, try using | grep ':9093' my alertmanager server port, I can not find any information, it seemed did not trigger any mail. is there any key words to identify? thanks

Edit -
Ok I will answer myself.
The problem is two fold:
local:
directory: /etc/loki/rules
rule_path: /tmp/rules

The second problem is your rules need to be in a sub-directory of /etc/loki/rules

Explanation:
rule-path is a bad choice of configuration option name by the loki team; it should have read rule-path-temp. This is the temp/working directory.

I hope this helps. The ruler documentation is crap/should be improved.

thanks
I gave up with loki’s alert function. and now, using grafana dashboard to send notice message to alertmanager.