<commit_before>include:
  - repos

prometheus:
  pkg.installed:
    - name: golang-github-prometheus-prometheus
    - require:
      - sls: repos

prometheus_configuration:
  file.managed:
    - name: /etc/prometheus/prometheus.yml
    - makedirs: True
    - contents: |
        scrape_configs:
          - job_name: 'sumaform'
            scrape_interval: 5s
            static_configs:
              - targets: ['{{grains["server"]}}:9100'] # node_exporter
              - targets: ['{{grains["server"]}}:9187'] # postgres_exporter
              - targets: ['{{grains["server"]}}:5556'] # jmx_exporter
              - targets: ['{{grains["server"]}}:5557'] # jmx_exporter taskomatic
              {% if grains["locust"] %}
              - targets: ['{{grains["locust"]}}:9500'] # locust_exporter
              {% endif %}
          - job_name: 'tomcat'
            scrape_interval: 5s
            metrics_path: /rhn/metrics
            static_configs:
              - targets: ['{{grains["server"]}}:80']
          - job_name: 'taskomatic'
            scrape_interval: 5s
            static_configs:
              - targets: ['{{grains["server"]}}:9800']

prometheus_service:
  file.managed:
    - name: /etc/systemd/system/prometheus.service
    - contents: |
        [Unit]
        Description=prometheus

        [Service]
        ExecStart=/usr/bin/prometheus -config.file=/etc/prometheus/prometheus.yml

        [Install]
        WantedBy=multi-user.target
    - require:
      - pkg: prometheus
  service.running:
    - name: prometheus
    - enable: True
    - require:
      - file: prometheus_service
      - file: prometheus_configuration
    - watch:
      - file: prometheus_configuration

grafana:
  pkg.installed:
    - name: grafana
    - require:
      - sls: repos

grafana_port_configuration:
  file.replace:<commit_msg>grafana: enable anonymous login<commit_after>include:
  - repos

prometheus:
  pkg.installed:
    - name: golang-github-prometheus-prometheus
    - require:
      - sls: repos

prometheus_configuration:
  file.managed:
    - name: /etc/prometheus/prometheus.yml
    - makedirs: True
    - contents: |
        scrape_configs:
          - job_name: 'sumaform'
            scrape_interval: 5s
            static_configs:
              - targets: ['{{grains["server"]}}:9100'] # node_exporter
              - targets: ['{{grains["server"]}}:9187'] # postgres_exporter
              - targets: ['{{grains["server"]}}:5556'] # jmx_exporter
              - targets: ['{{grains["server"]}}:5557'] # jmx_exporter taskomatic
              {% if grains["locust"] %}
              - targets: ['{{grains["locust"]}}:9500'] # locust_exporter
              {% endif %}
          - job_name: 'tomcat'
            scrape_interval: 5s
            metrics_path: /rhn/metrics
            static_configs:
              - targets: ['{{grains["server"]}}:80']
          - job_name: 'taskomatic'
            scrape_interval: 5s
            static_configs:
              - targets: ['{{grains["server"]}}:9800']

prometheus_service:
  file.managed:
    - name: /etc/systemd/system/prometheus.service
    - contents: |
        [Unit]
        Description=prometheus

        [Service]
        ExecStart=/usr/bin/prometheus -config.file=/etc/prometheus/prometheus.yml

        [Install]
        WantedBy=multi-user.target
    - require:
      - pkg: prometheus
  service.running:
    - name: prometheus
    - enable: True
    - require:
      - file: prometheus_service
      - file: prometheus_configuration
    - watch:
      - file: prometheus_configuration

grafana:
  pkg.installed:
    - name: grafana
    - require:
      - sls: repos

grafana_anonymous_login_configuration:
  file.blockreplace:
    - name: /etc/grafana/grafana.ini
    - marker_start: '#################################### Anonymous Auth ##########################'
    - marker_end: '#################################### Github Auth ##########################'
    - content: |
        [auth.anonymous]
        enabled = true
        org_name = Main Org.
        org_role = Admin
    - require:
      - pkg: grafana

grafana_port_configuration:
  file.replace:
{'fraction_non_alphanumeric': 0.15380906460945035, 'fraction_numerical': 0.013982642237222759, 'mean_word_length': 2.1289592760180995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5485577', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1265, 'n_words': 212}