zoukankan      html  css  js  c++  java
  • k8s记录-prometheus部署

    prometheus 安装

    官网:https://prometheus.io/download/

    wget https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz
    tar xvf prometheus-2.10.0.linux-amd64.tar.gz
    mv prometheus-2.10.0.linux-amd64 /usr/local/prometheus

    cd /usr/local/prometheus

    vim prometheus.yml

    scrape_configs:
      - job_name: 'prometheus'
        static_configs:
        # 监控本地及端口
        - targets: ['xiangsikai:9090']
    

    注:Prometheus从目标机上通过http方式拉取采样点数据, 它也可以拉取自身服务数据并监控自身的健康状况。

    启动服务

    ./prometheus --config.file=prometheus.yml
    # 指定配置文件
    --config.file="prometheus.yml"
    # 指定监听地址端口
    --web.listen-address="0.0.0.0:9090" 
    # 最大连接数
    --web.max-connections=512
    # tsdb数据存储的目录,默认当前data/
    --storage.tsdb.path="data/"
    # premetheus 存储数据的时间,默认保存15天
    --storage.tsdb.retention=15d 

    查看暴露指标:http://localhost.com:9090/metrics

    创建用户

    groupadd prometheus
    useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
    chown prometheus.prometheus -R /usr/local/prometheus
    创建Systemd服务

    cat > /etc/systemd/system/prometheus.service <<EOF
    [Unit]
    Description=prometheus
    After=network.target
    [Service]
    Type=simple
    User=prometheus
    ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/data
    Restart=on-failure
    [Install]
    WantedBy=multi-user.target
    EOF
    其他参数

    # 控制对admin HTTP API的访问,其中包括删除时间序列等功能
    --web.enable-admin-api

    # 支持热更新,直接执行localhost:9090/-/reload立即生效
    --web.enable-lifecycle

    # 热更新
    curl -X POST http://prometheous_ip:9090/-/reload
    启动Prometheus

    systemctl start prometheus

    验证Prometheus是否启动成功
    systemctl status prometheus

    开机启动
    systemctl enable prometheus
    访问自带Web

    自带Web默认http://ip:9090

  • 相关阅读:
    [转]批处理for命令使用指南
    批处理命令学习
    【树】Count Complete Tree Nodes
    【树】Flatten Binary Tree to Linked List(先序遍历)
    【树】Kth Smallest Element in a BST(递归)
    巧用border特性实现聊天气泡效果
    【树】Lowest Common Ancestor of a Binary Tree(递归)
    【树】Path Sum II(递归)
    【树】Populating Next Right Pointers in Each Node
    【树】Serialize and Deserialize Binary Tree
  • 原文地址:https://www.cnblogs.com/xinfang520/p/12916278.html
Copyright © 2011-2022 走看看