Helping the Industrial Internet of Things, the service domain of industrial big data: an introduction to Prometheus [36]

03: Introduction to Prometheus

  • Goal : Understand the functions and features of Prometheus

  • path

    • step1: function
    • step2: Features
  • implement

    • https://prometheus.io/

      image-20211005165514332

    • Function: server performance indicator monitoring and sequential data storage

      • Prometheus implements a high-latitude data model, and time series data consists of indicator names and key-value pairs.
      • PromQL allows slicing and dicing of collected time series data, generating ad-hoc graphs, charts, alerts
      • Prometheus has a variety of data visualization modes: built-in expression browser, grafana integration, console template language
      • Prometheus uses an efficient custom format to store time series data in memory and local disk, and elastically expands through functional sharding and federation.
      • Each server is self-contained and relies only on local storage. Written in go language, all binaries are statically linked for easy deployment.
      • Alerts are flexibly defined based on PromQL and retain dimension information. The alert manager controls whether alert information is notified or not.
    • features

      • Multidimensional data model.
      • Flexible query language.
      • Without relying on distributed storage, a single server node is autonomous.
      • Time-series data is collected through HTTP-based pull.
      • Time series data can be pushed through the intermediate gateway.
      • Discover target service objects through service discovery or static configuration.
      • Supports a variety of charts and interface displays, such as Grafana, etc.
  • summary

    • Understand the functions and features of Prometheus

04: Architecture of Prometheus

  • Goal : Understand the architecture of Prometheus

  • implement

    image-20211005172848417

    • Prometheus server : Prometheus master server, which collects and stores time series data

    • Aalert manager : handle alarm information

    • Push gateway : a push gateway that supports short-lived tasks

    • Client libraries: Client libraries for instrumenting application code

    • Exporters: Specific exporter services, such as: HAProxy, StatsD, Graphite and other services.

  • summary

    • Understand the architecture of Prometheus

05: Deployment of Prometheus

  • Goal : Realize the deployment of Prometheus

  • implement

    • upload decompression

      cd ~
      rz
      # 解压安装包
      tar zxvf prometheus-2.26.0.linux-amd64.tar.gz -C /opt
      # 修改文件名
      mv /opt/prometheus-2.26.0.linux-amd64/ /opt/prometheus-2.26
      # 进入解压后的安装包
      cd /opt/prometheus-2.26
      
    • verify

      ./prometheus --version
      
    • View configuration : prometheus.yml

      # 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:
            # - alertmanager:9093
      
      # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
      rule_files:
        # - "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.
        - job_name: 'prometheus'
      
          # metrics_path defaults to '/metrics'
          # scheme defaults to 'http'.
      
          static_configs:
          - targets: ['localhost:9090']
      
    • Register System Service

      vim /etc/systemd/system/prometheus.service
      
      [Unit]
      Description=Prometheus
      Documentation=Prometheus Monitoring System
      
      [Service]
      ExecStart=/opt/prometheus-2.26/prometheus --config.file=/opt/prometheus-2.26/prometheus.yml
      Restart=on-failure
      [Install]
      WantedBy=multi-user.target
      
    • start up

      # 设置开机自启动
      systemctl enable prometheus
      # 启动服务
      systemctl start prometheus
      # 查看服务状态
      systemctl status prometheus
      
    • Verify : node1:9090

      image-20211005174237698

  • summary

    • Realize the deployment of Prometheus

Guess you like

Origin blog.csdn.net/xianyu120/article/details/132326826