我有以下 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) 我不确定这是一个错误,但我试图在过去的一天中实现这个库,但没有任何结果。我认为这可能与依赖项版本冲突,但我尝试了一切。
所以我有一个非常简单的 spring boot 项目,它为/test
端点提供服务,我配置
现在我在/actuator/prometheus
.
期望的结果是指标将包含以下附加指标:
requests_test_total
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) 我正在尝试实现 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) prometheus ×2
apache-kafka ×1
async-await ×1
docker ×1
metrics ×1
monitoring ×1
python ×1
spring-boot ×1