-
-
Save hasanbasri1993/bb5785ca0e3cab73ddf5f2e8d161f45b to your computer and use it in GitHub Desktop.
# Configuration for telegraf agent | |
[agent] | |
## Default data collection interval for all inputs | |
interval = "1s" | |
## Rounds collection interval to 'interval' | |
## ie, if interval="10s" then always collect on :00, :10, :20, etc. | |
round_interval = true | |
## Telegraf will send metrics to outputs in batches of at most | |
## metric_batch_size metrics. | |
## This controls the size of writes that Telegraf sends to output plugins. | |
metric_batch_size = 1000 | |
## For failed writes, telegraf will cache metric_buffer_limit metrics for each | |
## output, and will flush this buffer on a successful write. Oldest metrics | |
## are dropped first when this buffer fills. | |
## This buffer only fills when writes fail to output plugin(s). | |
metric_buffer_limit = 10000 | |
## Collection jitter is used to jitter the collection by a random amount. | |
## Each plugin will sleep for a random time within jitter before collecting. | |
## This can be used to avoid many plugins querying things like sysfs at the | |
## same time, which can have a measurable effect on the system. | |
collection_jitter = "0s" | |
## Default flushing interval for all outputs. Maximum flush_interval will be | |
## flush_interval + flush_jitter | |
flush_interval = "1s" | |
## Jitter the flush interval by a random amount. This is primarily to avoid | |
## large write spikes for users running a large number of telegraf instances. | |
## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s | |
flush_jitter = "0s" | |
## By default or when set to "0s", precision will be set to the same | |
## timestamp order as the collection interval, with the maximum being 1s. | |
## ie, when interval = "10s", precision will be "1s" | |
## when interval = "250ms", precision will be "1ms" | |
## Precision will NOT be used for service inputs. It is up to each individual | |
## service input to set the timestamp at the appropriate precision. | |
## Valid time units are "ns", "us" (or "µs"), "ms", "s". | |
precision = "s" | |
## Logging configuration: | |
## Run telegraf with debug log messages. | |
debug = true | |
## Run telegraf in quiet mode (error log messages only). | |
quiet = false | |
## Specify the log file name. The empty string means to log to stderr. | |
logfile = "" | |
## Override default hostname, if empty use os.Hostname() | |
hostname = "" | |
## If set to true, do no set the "host" tag in the telegraf agent. | |
omit_hostname = false | |
[[outputs.influxdb_v2]] | |
## The URLs of the InfluxDB cluster nodes. | |
## | |
## Multiple URLs can be specified for a single cluster, only ONE of the | |
## urls will be written to each interval. | |
## urls exp: http://127.0.0.1:8086 | |
urls = ["http://influxdb:8086"] | |
## Token for authentication. | |
token = "bg8j0VGobiq779ZBbvKOdDwcEqUs4sbQzEs-M16y1LiA8qxXYYH6VbMFt0auDIxzvrrE9DAxnNSBR3zbANq2BQ==" | |
## Organization is the name of the organization you wish to write to; must exist. | |
organization = "TRIASGROUP" | |
## Destination bucket to write into. | |
bucket = "power_meter" | |
[[inputs.modbus]] | |
name = "PowerMeter" | |
slave_id = 1 | |
timeout = "1s" | |
busy_retries_wait = "100ms" | |
controller = "tcp://192.168.0.7:502" | |
holding_registers = [ | |
{ name = "CURRENT_A", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 30,31 ] }, | |
{ name = "CURRENT_B", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 34,35 ] }, | |
{ name = "CURRENT_C", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 38,39 ] }, | |
{ name = "VOLTAGE_AB", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 56,57 ] }, | |
{ name = "REAL_ENERGY", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 42,43 ] }, | |
{ name = "REACTIVE_POWER", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 48,49 ] }, | |
{ name = "POWER_FACTOR", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 46,47 ] }, | |
{ name = "REAL_POWER", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 44,45 ] }, | |
{ name = "FREQUENCY", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 74,75 ] }, | |
{ name = "RP/KWH", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 62,63 ] }, | |
{ name = "RUPIAH", byte_order = "ABCD", data_type = "FLOAT32-IEEE", scale = 1.0, address = [ 66,67 ] }, | |
] |
docker run -d --restart always --name=telegraf --net=influxdb -v C:\Users\USER\telegraf.conf:/etc/telegraf/telegraf.conf:ro telegraf
version: "3"
services:
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- 3000:3000
volumes:
- /Volumes/DATA1/IOT/grafana/grafana.ini:/etc/grafana/grafana.ini
- /Volumes/DATA1/IOT/grafana:/var/lib/grafana
networks:
my_network:
ipv4_address: 172.28.0.2
restart: always
environment:
GF_RENDERING_SERVER_URL: http://renderer:8081/render
GF_RENDERING_CALLBACK_URL: http://grafana:3000/
GF_LOG_FILTERS: rendering:debug
renderer:
container_name: renderer
image: grafana/grafana-image-renderer:latest
ports:
- 8081:8081
environment:
ENABLE_METRICS: 'true'
networks:
my_network:
ipv4_address: 172.28.0.3
influxdb:
image: influxdb:1.8.5
container_name: influxdb
ports:
- 8086:8086
volumes:
- /Volumes/DATA1/IOT/influxdb:/var/lib/influxdb
networks:
my_network:
ipv4_address: 172.28.0.4
restart: always
telegraf:
image: telegraf:latest
container_name: telegraf_sim
volumes:
- /Volumes/DATA1/IOT/telegraf/telegraf_sim.conf:/etc/telegraf/telegraf.conf:ro
restart: always
networks:
my_network:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
docker network create influxdb
docker run --rm telegraf telegraf config > telegraf.conf
docker run -d --restart always --name influxdb --net=influxdb -p 8086:8086 influxdb
docker run -d --restart always --name influxdb1.8 --net=influxdb -p 8087:8086 influxdb:1.8
docker run -d --restart always --name grafana --net=influxdb -p 3000:3000 -e "GF_INSTALL_PLUGINS=marcuscalidus-svg-panel,scadavis-synoptic-panel,grafana-clock-panel,natel-discrete-panel,gapit-htmlgraphics-panel,pierosavi-imageit-panel,aidanmountford-html-panel,aceiot-svg-panel" grafana/grafana
docker run -d --restart always --name=telegraf --net=influxdb -v /Users/hasanbasri1/telegraf.conf:/etc/telegraf/telegraf.conf:ro telegraf