小编Sha*_*ulu的帖子

使用 docker-compose 进行 Prometheus 服务发现

我有以下 docker-compose 文件:

version: '3.4'

services:
    serviceA:
        image: <image>
        command: <command>
        labels:
           servicename: "service-A"
        ports:
         - "8080:8080"

    serviceB:
        image: <image>
        command: <command>
        labels:
           servicename: "service-B"
        ports:
         - "8081:8081"

    prometheus:
        image: prom/prometheus:v2.32.1
        container_name: prometheus
        volumes:
          - ./prometheus:/etc/prometheus
          - prometheus_data:/prometheus
        command:
          - '--config.file=/etc/prometheus/prometheus.yml'
          - '--storage.tsdb.path=/prometheus'
          - '--web.console.libraries=/etc/prometheus/console_libraries'
          - '--web.console.templates=/etc/prometheus/consoles'
          - '--storage.tsdb.retention.time=200h'
          - '--web.enable-lifecycle'
        restart: unless-stopped
        expose:
          - 9090

        labels:
          org.label-schema.group: "monitoring"

volumes:
    prometheus_data: {}
Run Code Online (Sandbox Code Playgroud)

docker-compose 还包含具有以下配置的 Prometheus 实例:

global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.


scrape_configs:
  - job_name: …
Run Code Online (Sandbox Code Playgroud)

monitoring metrics docker docker-compose prometheus

5
推荐指数
1
解决办法
6840
查看次数

在 SpringBoot 中使用 prometheus 自定义指标

我不确定这是一个错误,但我试图在过去的一天中实现这个库,但没有任何结果。我认为这可能与依赖项版本冲突,但我尝试了一切。

所以我有一个非常简单的 spring boot 项目,它为/test端点提供服务,我配置

  1. 柜台
  2. 直方图

现在我在/actuator/prometheus.

期望的结果是指标将包含以下附加指标:

  1. requests_test_total
  2. requests_latency_seconds

我正在触发/test端点,但这些指标未显示在 prometheus 指标中。

我错过了什么吗?

这些是我的依赖项:

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-actuator')

    compile('io.micrometer:micrometer-registry-prometheus')

    compile "io.prometheus:simpleclient:0.8.1"
    compile "io.prometheus:simpleclient_hotspot:0.8.1"
    compile "io.prometheus:simpleclient_httpserver:0.8.1"
    compile "io.prometheus:simpleclient_pushgateway:0.8.1"
    compile group: 'io.prometheus', name: 'simpleclient_spring_boot', version: '0.8.1'

    compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
    compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
    compile group: 'ch.qos.logback.contrib', name: 'logback-json-classic', version: '0.1.5'
    compile group: 'ch.qos.logback.contrib', name: 'logback-jackson', version: '0.1.5'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.3'
    compile group: 'net.logstash.logback', …
Run Code Online (Sandbox Code Playgroud)

spring-boot spring-boot-actuator prometheus prometheus-java

4
推荐指数
1
解决办法
5760
查看次数

Aiokafka 库不会异步消费消息

我正在尝试实现 Python aiokafka 异步库,但由于某种原因我无法异步处理消息。

我创建了异步消费者、生产者并使用了 asyncio python 库。

环境:

 python 3.7.2
aiokafka==0.5.1
kafka-python==1.4.3
Run Code Online (Sandbox Code Playgroud)

消费者:

from aiokafka import AIOKafkaConsumer
import asyncio
import json
import ast

loop = asyncio.get_event_loop()

async def consume():
    consumer = AIOKafkaConsumer(
        "test_topic", loop=loop, bootstrap_servers='localhost:9092')
    # Get cluster layout and topic/partition allocation
    await consumer.start()
    try:
        async for msg in consumer:
            sleep_time = ast.literal_eval(json.loads(msg.value))
            print('before sleep %s' % sleep_time)
            await asyncio.sleep(sleep_time)
            print('after sleep %s' % sleep_time)
    finally:
        await consumer.stop()

loop.run_until_complete(consume())
Run Code Online (Sandbox Code Playgroud)

制作人:

import json
import uuid
from kafka import KafkaProducer, KafkaConsumer …
Run Code Online (Sandbox Code Playgroud)

python async-await apache-kafka python-asyncio

1
推荐指数
1
解决办法
1635
查看次数