influxdb1.8自身参数监控方案探索
1. 部署chronograf
chronograf:
image: chronograf
ports:
- 8888:8888
environment:
- INFLUXDB_URL=http://influxdb:8086
volumes:
- ./chronograf:/var/lib/chronograf
注意添加环境变量 INFLUXDB_URL=http://influxdb:8086, 这样在访问web页面时,可以设置url为http://influxdb:8086,否则默认的http://localhost:8086会连接失败
2. 部署telegraf
telegraf:
container_name: telegraf
image: telegraf
restart: always
volumes:
- /data/elements/config/telegraf.conf:/etc/telegraf/telegraf.conf:ro
environment:
- INFLUXDB_URL=http://influxdb:8086
生成telegraf.conf
docker run --rm telegraf telegraf config > ./telegraf.conf
配置telegraf.conf
[[outputs.influxdb]]
urls = ["http://influxdb:8086"]
database = "telegraf" #需要在influxdb中手动新建telegraf库
retention_policy = ""
write_consistency = "any"
timeout = "5s"
# HTTP Basic Auth
username = "admin"
password = "1qaz2wsx"
#下面的配置不确定是否需要
[[inputs.influxdb]]
urls = [
"http://influxdb:8086/debug/vars"
]
timeout = "5s"
3. 部署kapacitor
kapacitor:
container_name: kapacitor
image: kapacitor
ports:
- 9093:9092 #原先已部署kafka占用了9092
restart: always
volumes:
- /data/elements/config/kapacitor.conf:/etc/kapacitor/kapacitor.conf:ro
environment:
- INFLUXDB_URL=http://influxdb:8086
生成配置文件
docker run --rm kapacitor kapacitord config > ./kapacitor.conf
修改配置文件
hostname = "9c14c3d07097" #docker-compose中新建kapacitor后,修改容器名字
[[influxdb]]
urls = ["http://influxdb:8086"]
username = "admin"
password = "1qaz2wsx"
在chronograf页面的配置选项中,新建一个kapacitor的url为http://kapacitor:9092/
4. API获取一些指标
http://52.81.242.154:8086/debug/vars
http://52.81.242.154:9093/kapacitor/v1/debug/vars
API查询操作
https://blog.csdn.net/yue530tomtom/article/details/82686695
http访问查询
http://52.81.242.154:8086/query?db=telegraf&u=admin&p=1qaz2wsx&q=select * from cpu limit 10
curl访问查询
curl -G 'http://localhost:8086/query?db=telegraf&u=admin&p=1qaz2wsx&pretty=true' --data-urlencode 'q=SELECT * FROM "cpu" limit 10'
-G: 以get方式发送数据,默认就是get
"cpu"中的引号不要也行,用途是有特殊字符比如_需要用双引号包起来
数据库中 内部库 _internal各表说明
努力生活,融于自然