Kubernetes monitoring practice (2): Prometheus and feasible monitoring program of Sensu

Abstract: This article describes two possible K8s monitoring program: Prometheus and Sensu. Two programs can provide a comprehensive system-level monitoring data to help developers track performance, locate the fault K8s key components, receive alerts.

Further Reading: Kubernetes monitoring practices (1): works K8s and monitoring practice

A, K8s monitoring of Prometheus

1.1 Introduction

Prometheus is an open source tool for monitoring and early warning and micro-container services, features robust, suitable for the development process in the cloud administrators and developers and other interested parties. Prometheus timing of the polymerization index data in the configuration object, expression evaluation rule, present results, send warning.

Prometheus not only be able to monitor predefined indicators, but also to achieve multi-dimensional data model, in-depth analysis, and associate for a number of indicators, from various angles to provide data support for developers and administrators.

1.2 Work

Prometheus is a an additional layer K8s environment. Should first install custom data acquisition parameters and data acquisition time interval. Prometheus K8s both real-time monitoring node, timing analysis can be performed on the monitored data. Prometheus also against node failures such as the failure to send warning.

1.3 Prometheus Operator

Many users will confuse the controller and operator. K8s Operator means the Controller to add new objects to K8s API, the configuration management mode applications such as Prometheus. In short, operator is a controller for a particular area.

Prometheus PrometheusOperator simplifies the running K8s not necessary to change the configuration of K8s. Use Prometheus Operator can easily monitor K8s service. Prometheus can be run by .yml predefined file. Prometheus Operator can create, configure, monitor and manage all instances on K8s. When deploying new applications, K8s creates a new pod (container). Once created, the original pod will be destroyed. Prometheus continuous monitoring API, if inconsistencies are found, then create a new service or pod-based Prometheus configuration changes.

1.4 core components

As a robust monitoring tool, Prometheus pulls data from the service, the service does not need to take the initiative to push data. But Prometheus provide the push entrance, but served to push up data can not pull data.

In addition, Prometheus support for time series and index name and value pairs associated simplifies the monitoring of multi-cloud. Prometheus not only monitoring applications globally, but also to drill down to the micro level of service. Users can manage data query capabilities, understand the application status; PromQL can also be used to create charts and tables, data visualization, and generates a warning based on specific parameters.

Prometheus's Web console shows all the features and tools. Users can PromQL advanced regular expressions and search conditions created by the dataset and warning.

1.5 Advantages

Prometheus biggest advantage is simple and flexible, multi-dimensional data model monitoring can be achieved. Monitoring the user can build a container frame clusters, it may also incorporate Grafana, to further improve the level of visual monitoring data.

Prometheus can be configured to collect node, pod and service indicators by the local service discovery K8s. Users can directly define the expression, create warning, no need to switch back and forth at different monitoring systems.

Prometheus crawl ability to be integrated into K8s, Docker and StatsD and other tools. Users can also configure alert via Web GUI, management chart.

But Prometheus also shortcomings: data model is limited. Prometheus default data acquisition time series model both advantages and disadvantages: on the one hand, this model helps to capture data in a standard format; on the other hand, result in a standardized data format of the data model is limited. Prometheus and maintaining communication via discovery mechanism K8s, there is a delay.

Two, K8s monitoring of Sensu

2.1 Introduction

Sensu is a multi-container cloud infrastructure monitoring tools. Sensu agent is cross-platform event generator, the user can perform the health service check monitoring systems and services, as well as collecting and analyzing metrics, not only to provide early warning or event management, monitoring API, client libraries and multiple scripting or programming language plug-ins, also supports custom workflows, enrich Sensu ability.

By way of pulling Prometheus active fetch data, while the message communication mechanism Sensu bus is used by the publish / subscribe (Pub / Sub) in push or pull mode data.

Works 2.2

Sensu using local plug-in data acquisition from StatsD library, Prometheus exporter, Nagios plug-ins, SNMP traps and other mainstream programs. Unlike other monitoring tools Prometheus, Sensu out of the box, it supports multiple cloud environments, the user can provide high availability configuration framework.

Sensu provide event filter, mutator and operator handler, and supports the creation of automated workload model. In this way, data can be external monitoring tools and monitoring data Sensu of integration, event-based monitoring path.

Kubernetes monitoring practice (2): Prometheus and feasible monitoring program of Sensu

2.3 core components

Sensu optimized for K8s container auto-discovery capability. Users can K8s and Docker and other containers for easy configuration environment monitoring check and collector, also can configure multiple applications K8s check for all components and run on the K8s.

Sensu also supports local integration and plug-ins can be used in conjunction with logging tools and Prometheus. Users can run Sensu and Prometheus, processing different data sets. Sensu can collect StatsD metrics, and writes the result collection Prometheus.

Sensu also runs K8s environment. Sensu assumed that a start will be deployed in a container, and later decided to move entire application environments into other containers. After the migration is complete, Sensu agent still capable of running in the new environment, can also be found Sensu, because Sensu with automatic discovery mechanism.

Application of 2.4 K8s

Sensu scalability, may increase the deployment of applications and cloud environments continues to expand, to provide specific function monitoring service. Monitoring the number of objects Sensu is no upper limit, it will not increase the monitoring object becomes more complicated.

Three, Sensu K8s monitoring of + Prometheus

Sensu run and Prometheus can increase visibility monitoring, and realize the benefits of their complementary functions.

Works 3.1

SensuPrometheus Collector Sensu Check plug is polymerized query API to fetch data from Prometheus exporter or Prometheus. Influx to data acquisition (default), stored in STDOUT Graphite, JSON format.

SensuPrometheus Collector Sensu integrated workload automation capabilities and ability to crawl Prometheus data. The user can demand to design and implement warning receiver time codes. Sensu can also store data collected metrics to InfluxDB, Graphite, and other external timing Prometheus dataset.

3.2 Installation Sensu PrometheusCollector

Users can Sensu asset index database Bonsai find, download, share assets. Click Bonsai information page of the download button to download the asset definition Sensu back-end platform and architecture. Receive a check, when the filter, mutator or request handler, Sensu verified downloaded assets according to the asset definition.

After downloading the definition of assets, the assets can be registered by Sensu resource management command-line tool sensuctl, and then create a monitor workflows.

Prometheus collector under the definition of an asset and the corresponding Linux sensuctl command:

Kubernetes monitoring practice (2): Prometheus and feasible monitoring program of Sensu

Kubernetes monitoring practice (2): Prometheus and feasible monitoring program of Sensu

Kubernetes monitoring practice (2): Prometheus and feasible monitoring program of Sensu

Check below for the example of Prometheus Collector:

Kubernetes monitoring practice (2): Prometheus and feasible monitoring program of Sensu

Kubernetes monitoring practice (2): Prometheus and feasible monitoring program of Sensu

3.3 Advantages

Sensu run and Prometheus has the following advantages:

  • Both to monitor cluster health K8s can dynamically monitor the health of the surrounding infrastructure, and acquisition-related indicators.
  • Automatic discovery can not only realize the problem, but also to simplify monitoring processes through automated workflows.
  • Prometheus and run Sensu can get more context information to achieve more granular data analysis crawl.
  • Sensu communication standard password, the security agent may be acquired by a single transmission of data.
  • Ease of configuration management monitoring settings.
  • Be able to monitor the entire infrastructure.

Conclusions

Sensu can monitor the entire infrastructure, and a high level of customization, richer context. Prometheus model is robust, can realize the depth drill-down; Sensu is using industry-standard technologies and formats (such as Nagios and StatsD), monitoring of the entire infrastructure. Sensu can complement each other and Prometheus, providing more context-rich information.

As we depend on availability and fault deepening of the degree of software and software repair time is critical to the survival of the enterprise. Therefore, only fully understand the system in order to overcome these challenges, infrastructure and application monitoring is the key part. To take full advantage of the ability to K8s must implement unified monitoring solution to achieve effective convergence of old and new technologies.

Author: STEFAN THORPE

Original link: https://dzone.com/refcardz/monitoring-kubernetes

Starting in UAVStack intelligent operation and maintenance

Guess you like

Origin blog.51cto.com/14159827/2442539