OpenTelemetry + SigNoz
Documentation | OpenTelemetry (opens new window) Introduction | SigNoz (opens new window)
OpenTelemetry 专注于遥测数据(跟踪 (opens new window)、 指标 (opens new window)和 日志 (opens new window))的生成、收集、管理和导出。
SigNoz 是一个开源可观察性工具,提供一站式的跟踪、指标和日志管理和可视化。
# 安装 SigNoz
git clone -b main https://github.com/SigNoz/signoz.git
cd signoz/deploy/
docker compose -f docker/clickhouse-setup/docker-compose.yaml up -d
查看容器是否正常
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
01f044c4686a signoz/frontend:0.25.4 "nginx -g 'daemon of…" 2 minutes ago Up 9 seconds 80/tcp, 0.0.0.0:3301->3301/tcp signoz-frontend
86aa5b875f9f gliderlabs/logspout:v3.2.14 "/bin/logspout syslo…" 2 minutes ago Up 1 second 80/tcp signoz-logspout
58746f684630 signoz/alertmanager:0.23.1 "/bin/alertmanager -…" 2 minutes ago Up 9 seconds 9093/tcp signoz-alertmanager
2cf1ec96bdb3 signoz/query-service:0.25.4 "./query-service -co…" 2 minutes ago Up About a minute (healthy) 8080/tcp signoz-query-service
e9f0aa66d884 signoz/signoz-otel-collector:0.79.5 "/signoz-collector -…" 2 minutes ago Up 10 seconds 0.0.0.0:4317-4318->4317-4318/tcp signoz-otel-collector
8ff17aadac6a signoz/signoz-otel-collector:0.79.5 "/signoz-collector -…" 2 minutes ago Up About a minute 4317-4318/tcp signoz-otel-collector-metrics
d3d89d7d4581 clickhouse/clickhouse-server:22.8.8-alpine "/entrypoint.sh" 2 minutes ago Up 2 minutes (healthy) 0.0.0.0:8123->8123/tcp, 0.0.0.0:9000->9000/tcp, 0.0.0.0:9181->9181/tcp, 9009/tcp signoz-clickhouse
9db88aefb6ed signoz/locust:1.2.3 "/docker-entrypoint.…" 2 minutes ago Up 2 minutes 5557-5558/tcp, 8089/tcp load-hotrod
60bb3b77b4f7 bitnami/zookeeper:3.7.1 "/opt/bitnami/script…" 2 minutes ago Up 2 minutes 0.0.0.0:2181->2181/tcp, 0.0.0.0:2888->2888/tcp, 0.0.0.0:3888->3888/tcp, 8080/tcp signoz-zookeeper-1
98c7178b4004 jaegertracing/example-hotrod:1.30 "/go/bin/hotrod-linu…" 9 days ago Up 2 minutes 8080-8083/tcp hotrod
# 服务说明
- signoz-query-service:查询服务
- signoz-clickhouse:clickhouse 存储数据
- signoz-frontend:网页
- signoz-logspout:读取 docker 日志
- signoz-alertmanager:告警
- signoz-otel-collector:otel-collector
- signoz-otel-collector-metrics:otel-collector
- signoz-zookeeper-1:zookeeper,管理 clickhouse 多节点
- otel-migrator:clickhouse 单节点变多节点,数据迁移Set Up Distributed ClickHouse for SigNoz | SigNoz (opens new window)
- load-hotrod 和 hotrod:测试服务,可用删除
# 验证安装
访问 http://localhost:3301/
,查看是否正常。
默认情况下,日志和跟踪的保留期设置为7 天,指标的保留期设置为30 天。要更改此设置,请导航至SigNoz UI “设置” 页面上的 “常规” 选项卡。
hotrod 是测试服务,可以删除 从安装 SigNoz 的目录中,
deploy/docker/clickhouse-setup/docker-compose.yaml
在纯文本编辑器中打开 Docker Compose 文件。注释掉或删除services.hotrod
和services.load-hotrod
部分。
# 安装 OpenTelemetry collector
OpenTelemetry Binary Usage in Virtual Machine | SigNoz (opens new window)
docker-compose 已经安装了 OTel collector,业务服务可以直接将数据发送到 SigNoz 的 OTel collector。如果需要收集多台机器上的系统指标,就需要在每台被收集的机器上部署 OTel collector,然后再发送到 SigNoz 的 OTel collector。
# SpringBoot + OTel
Spring Boot OpenTelemetry Instrumentation | SigNoz (opens new window)
# 下载 agent
wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
# 配置启动参数
启动时设置环境变量,再添加一个 agent
OTEL_EXPORTER_OTLP_ENDPOINT="http://<IP of SigNoz Backend>:4317" OTEL_RESOURCE_ATTRIBUTES=service.name=<app_name>
java -javaagent:/path/to/opentelemetry-javaagent.jar -jar <myapp>.jar
或者添加虚拟机参数
java -javaagent:/path/opentelemetry-javaagent.jar \
-Dotel.exporter.otlp.endpoint=http://<IP of SigNoz Backend>:4317 \
-Dotel.resource.attributes=service.name=<app_name> \
-jar <myapp>.jar
opentelemetry-java 可用的启动参数 README.md (opens new window)
# 验证
发送一些请求,然后再查看 SigNoz,多出一些配置的应用。