Giter Site home page Giter Site logo

prometheus-nacos-sd's Introduction

prometheus-nacos-sd

Prometheus service discovery using nacos and file_sd_config.


Install

Precompiled binaries

Download from https://github.com/afghanistanyn/prometheus-nacos-sd/releases

manual build

git clone https://github.com/afghanistanyn/prometheus-nacos-sd
cd prometheus-nacos-sd
make buildx

Docker

docker pull afghanistanyn/prometheus-nacos-sd:v1.0
docker run -it -d -v /tmp:/tmp afghanistanyn/prometheus-nacos-sd --nacos.address=192.168.1.1:8848 --nacos.namespace=dev --output.file=/tmp/nacos_sd_dev.json
ls /tmp/nacos_sd_dev.json

Usage

  • run

    ./prometheus-nacos-sd --nacos.address=192.168.1.1:8848 --nacos.namespace=dev nacos.group=DEFAULT_GROUP --output.file=nacos_sd_dev.json --refresh.interval=30
    
  • default parameters

   nasos.address=localhost:8848
   nacos.namespace=public
   nacos.group=DEFAULT_GROUP
   refresh.interval=60


Generated json format

generated json should be follow prometheus file_sd_config format like below:

[
    {
        "targets": [
            "192.168.1.1:5066"
        ],
        "labels": {
            "__meta_context_path": "/miniapp-gateway",
            "__meta_nacos_group": "DEFAULT_GROUP",
            "__meta_nacos_namespace": "dev",
            "__meta_preserved_register_source": "SPRING_CLOUD",
            "__metrics_path__": "/miniapp-gateway/actuator/prometheus",
            "job": "miniapp-gateway"
        }
    },
    {
        "targets": [
            "192.168.1.1:5064"
        ],
        "labels": {
            "__meta_context_path": "/",
            "__meta_nacos_group": "DEFAULT_GROUP",
            "__meta_nacos_namespace": "dev",
            "__meta_preserved_register_source": "SPRING_CLOUD",
            "__metrics_path__": "/actuator/prometheus",
            "job": "web-gateway"
        }
    }
]

about prometheus metric path

we set __metrics_path__ to "/actuator/prometheus" by default.
but if you set metadata with key 'context_path' in your application metadata like below , we will rewrite it to "content_path/actuator/prometheus"
spring:
  cloud:
    nacos:
      discovery:
        server-addr: 192.168.1.1:8848
        namespace: dev
        metadata:
          context_path: ${server.servlet.context-path:/}

Example prometheus settings

The part of your prometheus.yml is probably as follows.

  scrape_configs:
      - job_name: 'nacos-discorvery'
        file_sd_configs:
        - files:
          - /apps/prometheus/conf/nacos_sd_dev.json
          - /apps/prometheus/conf/nacos_sd_test.json
          refresh_interval: 1m
    
        relabel_configs:
        - regex: 'preserved_register_source'
          action: labeldrop

prometheus-nacos-sd's People

Contributors

afghanistanyn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.