I want to check http status with telegraf, push that in InfluxDBv2 and use the data base in grafana.
I use these with with a local cluster. I configure the clust with:
version: "3.9"
services:
...
grafana:
image: grafana/grafana-oss
restart: unless-stopped
depends_on:
- influxdb
ports:
- 3000:3000
environment:
- GF_LOG_MODE=console file
volumes:
- ./grafana/grafana-storage:/var/lib/grafana
influxdb:
image: influxdb
restart: unless-stopped
environment:
- DOCKER_INFLUXDB_INIT_BUCKET=influx
- DOCKER_INFLUXDB_INIT_ORG=org
- DOCKER_INFLUXDB_INIT_USERNAME=user
- DOCKER_INFLUXDB_INIT_PASSWORD=pw
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=mytoken
ports:
- 8086:8086
telegraf:
image: telegraf
restart: unless-stopped
ports:
- 8092:8092
- 8094:8094
- 8125:8125
depends_on:
- influxdb
links:
- influxdb
volumes:
- ./telegraf/etc/telegraf.conf:/etc/telegraf/telegraf.conf:ro
...
I set the configuration of influxdb with:
[global_tags]
user = "admin"
[agent]
## Default data collection interval for all inputs
interval = "5s"
round_interval = true
metric_buffer_limit = 10000
flush_buffer_when_full = true
# HTTP/HTTPS request given an address a method and a timeout
[[inputs.http_response]]
## List of urls to query.
urls = ["http://xxx.xxx.xxx.xxx"]
## Set response_timeout (default 5 seconds)
response_timeout = "30s"
## HTTP Request Method
method = "GET"
[[outputs.influxdb_v2]]
# urls = ["http://influxdb2:8086"]
urls = ["http://localhost:8086"]
token = "mytoken"
organization = "org"
bucket = "influx"
The token and org, are not exactly those I used. I the problem is I currently neither can connect telegraf, nor grafana to Influxb.
Telegraf throws:
babel-telegraf-1 | 2022-04-14T15:29:43Z E! [outputs.influxdb_v2] When writing to [http://localhost:8086]: Post "http://localhost:8086/api/v2/write?bucket=influx&org=org": dial tcp 127.0.0.1:8086: connect: connection refused
babel-telegraf-1 | 2022-04-14T15:29:43Z E! [agent] Error writing to outputs.influxdb_v2: Post "http://localhost:8086/api/v2/write?bucket=influx&org=org": dial tcp 127.0.0.1:8086: connect: connection refused
Grafana when trying to connect throws:
babel-grafana-1 | logger=tsdb.influx_flux t=2022-04-14T15:31:14.49+0000 lvl=warn msg="Flux query failed" err="Post \"localhost:///api/v2/query?org=org\": unsupported protocol scheme \"localhost\"" query=buckets()
babel-grafana-1 | logger=context t=2022-04-14T15:31:14.49+0000 lvl=info msg="Request Completed" method=POST path=/api/ds/query status=400 remote_addr=172.20.0.1 time_ms=18 size=237 referer=http://localhost:3000/datasources/edit/Nb4txesnz/
But what I can is: curl http://localhost:8086/ping
It returns:
StatusCode : 204
StatusDescription : No Content
Content : {}
RawContent : HTTP/1.1 204 No Content
X-Influxdb-Build: OSS
X-Influxdb-Version: v2.2.0
Date: Thu, 14 Apr 2022 15:29:04 GMT
Headers : {[X-Influxdb-Build, OSS], [X-Influxdb-Version, v2.2.0], [Date, Thu, 14 Apr 2022 15:29:04 GMT]}
RawContentLength : 0