diff --git a/README.md b/README.md index c910697..a130eec 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,29 @@ Dashboards rely on the following softwares: This stack is also known as the **TIG** stack. +## Quickstart + +The easiest way to test is to use [Docker](https://www.docker.com/). Ensure you have `docker` and +`docker-compose` binary installed. + +Write your miner address, grafana username and grafana password: + +``` +vi docker/environment +``` + +Then start containers: + +``` +docker-compose up +``` + +## Going further + +You should secure [InfluxDB](https://docs.influxdata.com/influxdb/v1.7/administration/security/) by using encryption for +communication, tokens for authentication (one read-only token for Grafana, one write only for Telegraf). The stack +doesn't require Docker. + ## Disclaimer Telegraf is able to make API call on thrid-party services. Please read terms of service before going further. The diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..846397b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +--- +version: "2" +services: + influxdb: + container_name: influxdb + image: influxdb:1.7.10 + ports: + - "8083:8083" + - "8086:8086" + volumes: + - influxdb-storage:/var/lib/influxdb + restart: always + + grafana: + container_name: grafana + env_file: + - ./docker/environment + image: grafana/grafana:7.3.7 + volumes: + - grafana-storage:/var/lib/grafana + user: "472:472" + ports: + - "3000:3000" + links: + - "influxdb:influxdb" + restart: always + + telegraf: + container_name: telegraf + entrypoint: telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d + env_file: + - ./docker/environment + image: telegraf:1.15.4 + volumes: + - ./docker/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf + - ./telegraf:/etc/telegraf/telegraf.d + links: + - "influxdb:influxdb" + restart: always + +volumes: + influxdb-storage: + driver: local + grafana-storage: + driver: local diff --git a/docker/environment b/docker/environment new file mode 100644 index 0000000..b73163d --- /dev/null +++ b/docker/environment @@ -0,0 +1,3 @@ +MINER_ADDRESS= +GF_SECURITY_ADMIN_USER= +GF_SECURITY_ADMIN_PASSWORD= diff --git a/docker/telegraf.conf b/docker/telegraf.conf new file mode 100644 index 0000000..46b0811 --- /dev/null +++ b/docker/telegraf.conf @@ -0,0 +1,17 @@ +[global_tags] + +[agent] + interval = "60s" + round_interval = true + metric_batch_size = 1000 + metric_buffer_limit = 10000 + collection_jitter = "0s" + flush_interval = "60s" + flush_jitter = "0s" + precision = "" + hostname = "docker" + omit_hostname = false + +[[outputs.influxdb]] + database = "metrics" + urls = ["http://influxdb:8086"] diff --git a/telegraf/flexpool.conf b/telegraf/flexpool.conf index 3b69757..947ac35 100644 --- a/telegraf/flexpool.conf +++ b/telegraf/flexpool.conf @@ -1,45 +1,45 @@ [[inputs.http]] name_override = "flexpool_balance" - urls = ["https://flexpool.io/api/v1/miner/MINER_ADDRESS/balance"] + urls = ["https://flexpool.io/api/v1/miner/${MINER_ADDRESS}/balance"] data_format = "json" tagexclude = ["url"] [inputs.http.tags] - miner = "MINER_ADDRESS" + miner = "${MINER_ADDRESS}" [[inputs.http]] name_override = "flexpool_stats" - urls = ["https://flexpool.io/api/v1/miner/MINER_ADDRESS/stats"] + urls = ["https://flexpool.io/api/v1/miner/${MINER_ADDRESS}/stats"] data_format = "json" fieldpass = ["*hashrate", "*shares"] tagexclude = ["url"] json_query = "result" [inputs.http.tags] - miner = "MINER_ADDRESS" + miner = "${MINER_ADDRESS}" [[inputs.http]] name_override = "flexpool_workers" - urls = ["https://flexpool.io/api/v1/miner/MINER_ADDRESS/workers"] + urls = ["https://flexpool.io/api/v1/miner/${MINER_ADDRESS}/workers"] data_format = "json" tagexclude = ["url"] fieldpass = ["*hashrate", "*shares"] tag_keys = ["name"] json_query = "result" [inputs.http.tags] - miner = "MINER_ADDRESS" + miner = "${MINER_ADDRESS}" [[inputs.http]] name_override = "flexpool_paid" - urls = ["https://flexpool.io/api/v1/miner/MINER_ADDRESS/totalPaid"] + urls = ["https://flexpool.io/api/v1/miner/${MINER_ADDRESS}/totalPaid"] data_format = "json" tagexclude = ["url"] [inputs.http.tags] - miner = "MINER_ADDRESS" + miner = "${MINER_ADDRESS}" [[inputs.http]] name_override = "flexpool_daily_revenue_estimation" - urls = ["https://flexpool.io/api/v1/miner/MINER_ADDRESS/estimatedDailyRevenue"] + urls = ["https://flexpool.io/api/v1/miner/${MINER_ADDRESS}/estimatedDailyRevenue"] data_format = "json" tagexclude = ["url"] [inputs.http.tags] - miner = "MINER_ADDRESS" + miner = "${MINER_ADDRESS}"