Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and configuration of Prometheus

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Introduction

Prometheus is an open source system monitoring and alarm toolkit, and Prometheus joined the Cloud Native Computing Foundation in 2016 as the second project after Kubernetes.

The main features of Prometheus are:

A multidimensional data model in which time series data is identified by measurement names and key / value pairs

PromQL is a flexible query language that can take advantage of this dimension

Does not rely on distributed storage; a single server node is autonomous

Time series collection is carried out through the pull model on HTTP.

Support push of time series through intermediate gateway

Discover targets through service discovery or static configuration

2. The component Prometheus ecosystem consists of several components, many of which are optional:

Prometheus master server, which scrapes and stores time series data

Client library for detecting application code

A push gateway that supports short-term work

Dedicated exporters of services such as HAProxy,StatsD,Graphite

An alertmanager handles alerts

Various support tools

Most Prometheus components are written in Go, so they are easy to build and deploy as static binaries.

3. The following figure illustrates the architecture of Prometheus and some of its ecosystem components:

Prometheus removes metrics from detected jobs either directly or through mediation push gateways for short-term jobs. It stores all obsolete samples locally and runs rules on the data to summarize and record new time series in existing data or to generate alerts. Grafana or other API users can be used to visualize the collected data.

4. Helm environment is required for installation:

Helm install prometheus stable/prometheus

If the installation is successful, if you check the pod status, you will find that two of them are in pending status because you need to request a pv.

HostPath is used here to create a pv

ApiVersion: v1kind: PersistentVolumemetadata: name: prometheus-pv1spec: capacity: storage: 2Gi volumeMode: Filesystem accessModes:-ReadWriteOnce persistentVolumeReclaimPolicy: Retain hostPath: path: / app/prometheus/pv1

Check the pod status to find that a pod will report an error, and check whether the log reports an error or a different container name.

The real reason is that the permission of the hoatPath,pvc request used is not enough. Go to the worker node and add 777 permissions to the corresponding hostpath. This is the error report I saw through rancher.

Msg= "Error opening query log file" file=/data/queries.active err= "open / data/queries.active: permission denied" 5. Visit the web interface

You also need to change the Port type of Prometheus-server to NodePort.

6. Install grafana

Helm pull stable/grafana

Tar xvf grafana-4.2.2.tgz

Vim grafana/values.yaml # set the password of admin to admin123

Helm install grafana. / grafana

Since grafana does not use persistent storage, it is modified to hostpath persistent storage according to the demand. It should be noted that the host directory also requires 777 permissions.

You also need to change the svc type of grafana to NodePort.

Access the web interface, user admin, password: admin123

7. Import Prometheus

Fill in the address of Prometheus

Then the verification is passed.

Import the template of grafana

Choose Prometheus here

You can see the magnificent dashboard.

Here are the numbers of several templates:

10000,315,7249,5228,8685,8588

A perfect end!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report