Promethus-day4-监控不携带metrics接口的服务
发布日期:2021-05-10 01:01:22 浏览次数:38 分类:精选文章

本文共 3499 字,大约阅读时间需要 11 分钟。

������������������������

1. ������Prometheus������������

1.1 ������������

  • ���������������Nginx���
    [root@k8s-master1]# cat /etc/nginx/conf.d/status.conf
    server {
    listen 8081;
    location / {
    stub_status;
    }
    }
  • ������Prometheus���Grafana���
    [root@k8s-master1]# mkdir exporter-nginx
    [root@k8s-master1]# cd exporter-nginx
    [root@k8s-master1]# vim exporter-nginx-deployment.yaml

1.2 ������Prometheus Exporter

  • ���������������������
    cat > exporter-nginx-deployment.yaml
  • ���������������
    [root@k8s-master1 exporter-nginx]# kubectl apply -f exporter-nginx-deployment.yaml
  • ���������������������������
    cat > exporter-service.yaml

    ���������������

    [root@k8s-master1 exporter-nginx]# kubectl apply -f exporter-service.yaml

1.3 ������EndPrints

  • ���������������
    [root@k8s-master1 exporter-nginx]# kubectl apply -f endpoint-service.yaml

1.4 ServiceMonitor������

  • ������ServiceMonitor���������������
    cat > service-monitor.yaml
  • ������ServiceMonitor���
    [root@k8s-master1 exporter-nginx]# kubectl apply -f service-monitor.yaml

1.5 ������������������Grafana���

  • ������������������������
    [root@k8s-master1 exporter-nginx]# kubectl get servicemonitor -n monitoring

2. ������Redis

2.1 ������Redis

  • ������Redis���
    [root@k8s-master1]# yum install redis\*
    [root@k8s-master1]# systemctl enable --now redis
  • ������Redis���������
    cat > redis-deploy.yaml

    ���������

    [root@k8s-master1 exporter-redis]# kubectl apply -f redis-deploy.yaml

2.2 ������Redis Exporter

  • ������Redis Exporter���
    [root@k8s-master1 exporter-redis]# wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
  • ������Redis Exporter���
    [root@k8s-master1 exporter-redis]# tar -xf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /usr/local/
    [root@k8s-master1 exporter-redis]# nohup /usr/local/mysqld_exporter-0.12.1/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter-0.12.1/.my.cnf &

3. ������MySQL���MariaDB���

3.1 ������MariaDB

  • ������MariaDB���
    [root@k8s-master1]# yum install mariadb\*
    [root@k8s-master1]# systemctl enable --now mariadb
  • ���������������������
    [root@k8s-master1]# mysql -u mysql_monitor -h localhost -p
    GRANT SELECT, REPLICATION CLIENT, PROCESS ON \*.\* TO 'mysql_monitor'@'%' IDENTIFIED BY 'oldboy@123';

3.2 ������MySQL Exporter

  • ������MySQL Exporter���

    [root@k8s-master1 exporter-mysql]# wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
  • ������MySQL Exporter���

    [root@k8s-master1 exporter-mysql]# tar -xf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /usr/local/
  • ������MariaDB���������������

    [root@k8s-master1]# vim /usr/local/mysqld_exporter-0.12.1/.my.cnf

    ���������������

    [client]
    user=mysql_monitor
    password=123
  • ���������������

    [root@k8s-master1 exporter-mysql]# nohup /usr/local/mysqld_exporter-0.12.1/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter-0.12.1/.my.cnf &

4. ������������Exporter

4.1������������

  • ���������������Exporter���
    [root@k8s-master1]# wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
  • ������������������
    [root@k8s-master1]# tar -xf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /usr/local/
  • ���������������
    [root@k8s-master1]# nohup /usr/local/mysqld_exporter-0.12.1/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter-0.12.1/.my.cnf &

Each section follows a clear, step-by-step format to ensure ease of understanding and execution, providing a comprehensive guide for deploying a monitoring system.

上一篇:Promethus-day5-配置文件详解+AlertManager微信邮件告警配置
下一篇:Promethus-day3-监控携带metriecs接口的服务

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月28日 05时24分32秒