This is the 8th day of my participation in the August More Text Challenge

1.prometheus

1.1 What is Prometheus?

Prometheus is an open-source monitoring and alarm solution created by SoundCloud, which has been coding for Prometheus since 2012 and open-source on Github since 2015. Prometheus has garnered 31.5K + views and has been used by many large companies; In 2016, Prometheus became the second member of Cloud Native Computing Foundation (CNCF) after K8S.

1.2 Main Functions

  • Multidimensional data model (timing is made up of metric names and labels of K/V).
  • Flexible query statement (PromQL).
  • Non-dependent storage, supports local and remote models.
  • Using HTTP protocol, using pull mode, pull data, easy to understand.
  • Monitor the target, either through service discovery or static configuration.
  • Support a variety of statistical data models, graphical friendly.

1.3 Estimating disk Capacity

  • On average, Prometheus uses only about 1-2 bytes per sample
  • 1GB = 1073741824 bytes ≈ 536870912 sample data (2 bytes per sample)

1.4 Infrastructure

Download prometheus. IO /download/

MAC: Prometheus – 2.29.0 – rc. 0. Darwin – amd64. Tar. Gz

tar xvfz prometheus-.tar.gz cd prometheus-

Xx_exporter provides monitoring of various applications from mysqLD_exporter to monitor Linux machines from consul registries

Yml job_name: job name scrape_interval: interval targets: target machine to be monitored

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
    monitor: 'codelab-monitor'

# 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'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:9090']
Copy the code

Start the Prometheus

Binary data is stored in the./data file

Start Prometheus. # By default, Prometheus stores its database in ./data (flag –storage.tsdb.path).

./prometheus --config.file=prometheus.yml
Copy the code

You can specify labels for the monitoring job

Let’s group all three endpoints into a single node. We’ll imagine that the first two endpoints are production targets and the third one represents the canary instance. To model this in Prometheus, we can add groups of endpoints to a single job, adding additional labels to each group of targets. In this case, we add the group=”production” tag to the first group of targets and group=”canary” to the second group.

scrape_configs:
  - job_name:       'node'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:8080'.'localhost:8081']
        labels:
          group: 'production'

      - targets: ['localhost:8082']
        labels:
          group: 'canary'
Copy the code

Prometheus adds a few more simple views

Go to http://localhost:9090/graph