# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets: ['${ALERT_MANAGER_ADDRESS}:${ALERT_MANAGER_PORT}']

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "instance-down-rules.yml"
# - "first_rules.yml"
# - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label "job='job_name'"" to any timeseries scraped from this config.
  # Monitored information captured by prometheus
  - job_name: 'node-exporter'
    static_configs:
      - targets: [ '${NODE_EXPORTER_ADDRESS}:${NODE_EXPORTER_PORT}' ]
        labels:
          namespace: 'default'

  # prometheus fetches application services
  - job_name: 'openimserver-openim-api'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${API_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-msggateway'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${MSG_GATEWAY_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-msgtransfer'
    static_configs:
      - targets: [ ${MSG_TRANSFER_PROM_ADDRESS_PORT} ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-push'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${PUSH_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-rpc-auth'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${AUTH_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-rpc-conversation'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${CONVERSATION_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-rpc-friend'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${FRIEND_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-rpc-group'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${GROUP_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-rpc-msg'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${MESSAGE_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-rpc-third'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${THIRD_PROM_PORT}' ]
        labels:
          namespace: 'default'
  - job_name: 'openimserver-openim-rpc-user'
    static_configs:
      - targets: [ '${DOCKER_BRIDGE_GATEWAY}:${USER_PROM_PORT}' ]
        labels:
          namespace: 'default'
