最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

prometheus數(shù)據(jù)遠(yuǎn)程寫入elasticsearch方式

 更新時(shí)間:2025年06月23日 09:47:42   作者:yololee_  
這篇文章主要介紹了prometheus數(shù)據(jù)遠(yuǎn)程寫入elasticsearch方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

prometheus數(shù)據(jù)遠(yuǎn)程寫入elasticsearch

一、部署elasticsearch

version: '3'

# 網(wǎng)橋es -> 方便相互通訊
networks:
  es:
    driver: bridge

services:
  elasticsearch:
    image: elasticsearch:7.14.1
    container_name: elasticsearch             # 容器名為'elasticsearch'
    restart: unless-stopped                           # 指定容器退出后的重啟策略為始終重啟,但是不考慮在Docker守護(hù)進(jìn)程啟動(dòng)時(shí)就已經(jīng)停止了的容器
    volumes:                                  # 數(shù)據(jù)卷掛載路徑設(shè)置,將本機(jī)目錄映射到容器目錄
      - "./elasticsearch/data:/usr/share/elasticsearch/data"
      - "./elasticsearch/logs:/usr/share/elasticsearch/logs"
      - "./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
#      - "./elasticsearch/config/jvm.options:/usr/share/elasticsearch/config/jvm.options"
      - "./elasticsearch/plugins/ik:/usr/share/elasticsearch/plugins/ik" # IK中文分詞插件
    environment:                              # 設(shè)置環(huán)境變量,相當(dāng)于docker run命令中的-e
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
      TAKE_FILE_OWNERSHIP: "true"  # 權(quán)限
      discovery.type: single-node
      ES_JAVA_OPTS: "-Xmx512m -Xms512m"
      ELASTIC_PASSWORD: "123456" # elastic賬號(hào)密碼
    ports:
      - "9200:9200"
      - "9300:9300"
    networks:
      - es

  kibana:
    image: kibana:7.14.1
    container_name: kibana
    restart: unless-stopped
    volumes:
      - ./elasticsearch/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
    ports:
      - "5601:5601"
    depends_on:
      - elasticsearch
    links:
      - elasticsearch
    networks:
      - es

其中的配置文件和插件查看地址:https://gitee.com/huanglei1111/docker-compose/tree/master/Linux/elasticsearch

查看是否運(yùn)行成功

訪問elasticsearch:ip:端口

訪問kibana:ip:端口

  • 用戶名:elastic
  • 密碼:123456

二、部署prometheus

version: "3"

# 網(wǎng)橋 -> 方便相互通訊
networks:
  prometheus:
    ipam:
      driver: default
      config:
        - subnet: "172.22.0.0/24"
services:
  # 開源的系統(tǒng)監(jiān)控和報(bào)警系統(tǒng)
  prometheus:
    image: prom/prometheus:v2.34.0
    container_name: hl-prometheus
    restart: unless-stopped
    volumes:
      - ./config/prometheus.yml:/etc/prometheus/prometheus.yml
      # - "./web-config.yml:/etc/prometheus/web-config.yml"
    command: 
      --config.file=/etc/prometheus/prometheus.yml
      --web.enable-lifecycle
      # --web.config.file=/etc/prometheus/web-config.yml
    ports:
      - "19090:9090"
    depends_on:
      - hl-node-exporter
    networks:
      prometheus:
        ipv4_address: 172.22.0.11

  # 采集服務(wù)器層面的運(yùn)行指標(biāo)
  node-exporter:
    image: prom/node-exporter:v1.3.1
    container_name: hl-node-exporter
    restart: unless-stopped
    volumes:
      - "./node-exporter/proc:/host/proc:ro"
      - "./node-exporter/sys:/host/sys:ro"
      - "./node-exporter:/rootfs:ro"
    ports:
      - "19100:9100"
    networks:
      prometheus:
        ipv4_address: 172.22.0.22
  # 使用prometheusbeat 把prometheus的數(shù)據(jù)存儲(chǔ)到elasticsearch中
  beat:
    image: infonova/prometheusbeat
    container_name: hl-prometheusbeat
    ports:
      - 18081:8080
    depends_on:
      - hl-prometheus
    volumes:
      - "./config/prometheusbeat.yml:/prometheusbeat.yml"
      - "/etc/localtime:/etc/localtime"
    networks:
      prometheus:
         ipv4_address: 172.22.0.33

相關(guān)配置文件查看地址:https://gitee.com/huanglei1111/docker-compose/tree/master/Linux/prometheus/prometheus-es/config

查看是否部署成功

查看監(jiān)控指標(biāo)是否健康

注意:狀態(tài)為down,注意修改prometheus.yml配置文件中targets的ip為服務(wù)器ip

三、通過prometheusbeat寫入數(shù)據(jù)到es

上面在部署docker-compose-prometheus.yml文件已經(jīng)部署啦

如果es有用戶密碼,需要在prometheusbeat.yml配置文件中添加配置

prometheusbeat:
  # prometheusbeat 服務(wù)的端口。默認(rèn)為8080
  listen: ":8080"
  # Context path. Defaults to /prometheus
  context: "/prometheus"
output.elasticsearch:
  # elasticsearch 的地址
  hosts: ["127.0.0.1:9200"]
  username: "elastic"
  password: "123456"

其次修改prometheus.yml配置文件

prometheus 通過 remote_write 來實(shí)現(xiàn)遠(yuǎn)端存儲(chǔ),所以在 prometheus.yml 配置文件中增加 remote_write 參數(shù)

global:
  scrape_interval: 10s
  scrape_timeout: 10s
  evaluation_interval: 10m
remote_write:
# 遠(yuǎn)程寫入到prometheusbeat中
- url: "http://127.0.0.1:18081/prometheus"
  write_relabel_configs:
  - source_labels: [__name__]
    action: keep
    regex: go_gc_cycles_automatic_gc_cycles_total
  remote_timeout: 30s
scrape_configs:
  # prometheus
  - job_name: prometheus
    static_configs:
      - targets: ['127.0.0.1:19090']
        labels:
          instance: prometheus

  # 采集node exporter監(jiān)控?cái)?shù)據(jù),即linux
  - job_name: linux
    static_configs:
      - targets: ['127.0.0.1:19100']
        labels:
          instance: localhost

配置說明

  • url:prometheusbeat 的服務(wù)地址
  • write_relabel_configs:這個(gè)很有用,用于過濾數(shù)據(jù),可以設(shè)置多個(gè)過濾條件,同時(shí)滿足這些條件的數(shù)據(jù)才會(huì)被存到遠(yuǎn)端存儲(chǔ)!
  • source_labels:根據(jù)哪個(gè)字段進(jìn)行過濾
  • regex:值過濾的規(guī)則
  • action:keep(保留)/drop(丟棄)

所以,上面配置文件中的配置意思就是:prometheus 收到數(shù)據(jù)后,遠(yuǎn)程發(fā)送給 prometheusbeat,并且只發(fā)送 name 為 go_gc_cycles_automatic_gc_cycles_total

然后重啟prometheus。之后當(dāng)收集到數(shù)據(jù)時(shí),就能成功保存到 elasticsearch 了,首次保存時(shí)會(huì)自動(dòng)創(chuàng)建索引:prometheusbeat-7.3.1,數(shù)據(jù)都存在此索引中。

四、elasticsearch head驗(yàn)證

我們通過瀏覽器安裝elasticsearch head插件,發(fā)現(xiàn)已經(jīng)多了這個(gè)索引了

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java中finally和return的關(guān)系實(shí)例解析

    Java中finally和return的關(guān)系實(shí)例解析

    這篇文章主要介紹了Java中finally和return的關(guān)系實(shí)例解析,總結(jié)了二者的關(guān)系,然后分享了相關(guān)代碼示例,小編覺得還是挺不錯(cuò)的,具有一定借鑒價(jià)值,需要的朋友可以參考下
    2018-02-02
  • 基于SpringBoot實(shí)現(xiàn)一個(gè)方法級(jí)耗時(shí)監(jiān)控器

    基于SpringBoot實(shí)現(xiàn)一個(gè)方法級(jí)耗時(shí)監(jiān)控器

    本文介紹基于SpringBoot實(shí)現(xiàn)的輕量級(jí)耗時(shí)監(jiān)控器,通過AOP攔截方法并分級(jí)存儲(chǔ)數(shù)據(jù),提供可視化統(tǒng)計(jì)界面,支持調(diào)用次數(shù)、耗時(shí)、失敗次數(shù)分析及多維排序,適合中小型項(xiàng)目快速集成,無需復(fù)雜配置,需要的朋友可以參考下
    2025-09-09
  • 深入理解 Java注解及實(shí)例

    深入理解 Java注解及實(shí)例

    這篇文章主要介紹了深入理解 Java注解及實(shí)例的相關(guān)資料,希望通過本文大家能夠掌握java注解的知識(shí),需要的朋友可以參考下
    2017-09-09
  • Springcloud Config配置中心使用與相關(guān)介紹

    Springcloud Config配置中心使用與相關(guān)介紹

    springcloud config是一個(gè)解決分布式系統(tǒng)的配置管理方案。它包含了 client和server兩個(gè)部分,server端提供配置文件的存儲(chǔ)、以接口的形式將配置文件的內(nèi)容提供出去,client端通過接口獲取數(shù)據(jù)、并依據(jù)此數(shù)據(jù)初始化自己的應(yīng)用
    2022-09-09
  • 利用Java Set 去除重復(fù)object的方法

    利用Java Set 去除重復(fù)object的方法

    下面小編就為大家?guī)硪黄肑ava Set 去除重復(fù)object的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-01-01
  • java讀取郵件excel附件的方法過程示例

    java讀取郵件excel附件的方法過程示例

    這篇文章主要介紹了java讀取郵件excel附件的方法過程示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • java中文轉(zhuǎn)全拼工具類分享

    java中文轉(zhuǎn)全拼工具類分享

    這篇文章主要介紹了一個(gè)JAVA將漢字轉(zhuǎn)換為全拼的工具類,大參考使用吧
    2014-01-01
  • java正則表達(dá)式用法大全(深度好文)

    java正則表達(dá)式用法大全(深度好文)

    這篇文章主要給大家介紹了關(guān)于java正則表達(dá)式用法大全的相關(guān)資料,正則表達(dá)式在處理字符串時(shí)非常有用,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-10-10
  • Java實(shí)現(xiàn)List分組的常見方法詳解

    Java實(shí)現(xiàn)List分組的常見方法詳解

    這篇文章主要為大家詳細(xì)介紹了使用Java實(shí)現(xiàn)List分組的幾個(gè)常見方法,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-12-12
  • SpringMVC如何在生產(chǎn)環(huán)境禁用Swagger的方法

    SpringMVC如何在生產(chǎn)環(huán)境禁用Swagger的方法

    本篇文章主要介紹了SpringMVC如何在生產(chǎn)環(huán)境禁用Swagger的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-02-02

最新評(píng)論

城步| 惠州市| 东安县| 边坝县| 双辽市| 镇巴县| 社旗县| 洛川县| 泉州市| 金堂县| 杂多县| 南皮县| 潍坊市| 塔城市| 莲花县| 莒南县| 梓潼县| 泌阳县| 洛阳市| 霍山县| 浏阳市| 巴东县| 津市市| 玉林市| 苍梧县| 察隅县| 咸阳市| 颍上县| 沙田区| 麦盖提县| 柯坪县| 德庆县| 霸州市| 石渠县| 浦城县| 庆城县| 昌邑市| 贵港市| 温泉县| 阜宁县| 铜梁县|