diff --git a/.env_example b/.env_example index 74ce5df6..2f54d225 100644 --- a/.env_example +++ b/.env_example @@ -7,10 +7,10 @@ BLOCK_RESULT_OPERATOR_PRIVATE_KEY= # if running rudder and all supporting services using docker compose NODE_ETHEREUM_MAINNET=http://hardhat-node:8545/ -IPFS_PINNER_URL=http://ipfs-pinner:3000 +IPFS_PINNER_URL=http://ipfs-pinner:3001 EVM_SERVER_URL=http://evm-server:3002 # if running rudder locally and all other services using docker compose NODE_ETHEREUM_MAINNET=http://127.0.0.1:8545/ -IPFS_PINNER_URL=http://127.0.0.1:3000 +IPFS_PINNER_URL=http://127.0.0.1:3001 EVM_SERVER_URL=http://127.0.0.1:3002 \ No newline at end of file diff --git a/.envrc b/.envrc index 5850f87e..387aeca7 100644 --- a/.envrc +++ b/.envrc @@ -1,5 +1,5 @@ export ERIGON_NODE="https://ethereum.web3.covalenthq.com/mainnet/rpc" -export IPFS_PINNER_URL="http://127.0.0.1:3000" +export IPFS_PINNER_URL="http://127.0.0.1:3001" export EVM_SERVER_URL="http://127.0.0.1:3002" [[ -f .envrc.local ]] && source_env .envrc.local \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7ab2ec12..6569de57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,4 +50,6 @@ COPY --from=builder-elixir /mix/test-data/ /app/test-data # Used only for testing in compose # CMD [ "mix", "test", "./test/block_specimen_decoder_test.exs", "./test/block_result_uploader_test.exs"] -CMD ["/app/prod/bin/rudder", "start"] \ No newline at end of file +CMD ["/app/prod/bin/rudder", "start"] + +EXPOSE 9568 \ No newline at end of file diff --git a/README.md b/README.md index 4cb13d49..80fb8b57 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,12 @@ - [Environment](#environment) - [Pull](#pull) - [Run](#docker-run) + - [Monitor](#monitor) - [Build & Run From Source](#build-from-source) - [Linux x86_64](#linux-x86_64-ubuntu-2204-lts-install-dependencies) - [Environment](#env-vars) - [Run](#source-run) + - [Monitor](#monitor) - [Troubleshooting](#troubleshooting) - [Bugs Reporting & Contributions](#bugs-reporting-contributions) - [Scripts](#scripts) @@ -170,7 +172,7 @@ Create `envrc.local` file and add the following env vars. ```bash export BLOCK_RESULT_OPERATOR_PRIVATE_KEY=block-result-operator-private-key-without-0x-prefix export NODE_ETHEREUM_MAINNET="https://moonbeam-alphanet.web3.covalenthq.com/alphanet/direct-rpc" -export IPFS_PINNER_URL="http://ipfs-pinner:3000" +export IPFS_PINNER_URL="http://ipfs-pinner:3001" export EVM_SERVER_URL="http://evm-server:3002" export WEB3_JWT="****" ``` @@ -193,7 +195,7 @@ This shows that the shell is loaded correctly. You can check if they're what you ```bash echo $IPFS_PINNER_URL -http://ipfs-pinner:3000 +http://ipfs-pinner:3001 ``` ### Pull @@ -271,7 +273,7 @@ Hence there is a single binary per "Environment". To understand more about this rudder | moonbase-node: https://moonbeam-alphanet.web3.covalenthq.com/alphanet/direct-rpc rudder | brp-operator: ecf0b636233c6580f60f50ee1d809336c3a76640dbd77f7cdd054a82c6fc0a31 rudder | evm-server: http://evm-server:3002 - rudder | ipfs-node: http://ipfs-pinner:3000 + rudder | ipfs-node: http://ipfs-pinner:3001 ipfs-pinner | 2023/04/19 16:53:31 Listening... rudder | ==> nimble_options rudder | Compiling 3 files (.ex) @@ -358,6 +360,11 @@ Once the binary is compiled. Rudder can start to process block specimens into bl rudder | [info] Summary for rudder_metrics - {0.0035489999999999996, 0.0035489999999999996} rudder | [info] curr_block: 4180658 and latest_block_num:4180657 ``` +### Monitor + +`rudder`already captures the most relevant performance metrics and execution times for various processes in the pipeline and exports all of it using Prometheus. + +See the full document on how to setup Prometheus and Grafana for [rudder metrics collection, monitoring, reporting and alerting](./docs/metrics.md) ## Build From Source diff --git a/config/config.exs b/config/config.exs index d0323c14..760ae83e 100644 --- a/config/config.exs +++ b/config/config.exs @@ -8,7 +8,7 @@ import Config config :rudder, - ipfs_pinner_url: System.get_env("IPFS_PINNER_URL", "http://127.0.0.1:3000"), + ipfs_pinner_url: System.get_env("IPFS_PINNER_URL", "http://127.0.0.1:3001"), operator_private_key: System.get_env("BLOCK_RESULT_OPERATOR_PRIVATE_KEY"), proofchain_address: "0x4f2E285227D43D9eB52799D0A28299540452446E", proofchain_chain_id: 1284, diff --git a/config/docker.exs b/config/docker.exs index 564148de..2f295159 100644 --- a/config/docker.exs +++ b/config/docker.exs @@ -5,5 +5,5 @@ config :rudder, proofchain_address: "0xCF3d5540525D191D6492F1E0928d4e816c29778c", proofchain_chain_id: 31337, proofchain_node: "http://hardhat-node:8545/", - ipfs_pinner_url: "http://ipfs-pinner:3000", + ipfs_pinner_url: "http://ipfs-pinner:3001", evm_server_url: "http://evm-server:3002" diff --git a/config/test.exs b/config/test.exs index 06170d64..2c51b0f7 100644 --- a/config/test.exs +++ b/config/test.exs @@ -5,5 +5,5 @@ config :rudder, proofchain_address: "0xCF3d5540525D191D6492F1E0928d4e816c29778c", proofchain_chain_id: 31337, proofchain_node: "http://127.0.0.1:8545/", - ipfs_pinner_url: "http://127.0.0.1:3000", + ipfs_pinner_url: "http://127.0.0.1:3001", evm_server_url: "http://127.0.0.1:3002" diff --git a/docker-compose-ci.yml b/docker-compose-ci.yml index 00971eb9..7c3e35f1 100644 --- a/docker-compose-ci.yml +++ b/docker-compose-ci.yml @@ -47,14 +47,14 @@ services: restart: on-failure expose: - "4001:4001" - - "3000:3000" + - "3001:3001" environment: - WEB3_JWT=${WEB3_JWT} networks: - cqt-net ports: - "4001:4001" - - "3000:3000" + - "3001:3001" evm-server: image: "us-docker.pkg.dev/covalent-project/network/evm-server:latest" @@ -94,8 +94,8 @@ services: done; echo Proof-chain contracts deployed!; echo Uploading test files to local .ipfs...; - curl -F "filedata=@/app/test-data/codec-0.35/encoded/1-17090940-replica-0x7b8e1d463a0fbc6fce05b31c5c30e605aa13efaca14a1f3ba991d33ea979b12b" http://ipfs-pinner:3000/upload; - curl -F "filedata=@/app/test-data/codec-0.35/encoded/1-17090960-replica-0xc95d44182ee006e79f1352ef32664210f383baa016988d5ab2fd950b52bf22ff" http://ipfs-pinner:3000/upload; + curl -F "filedata=@/app/test-data/codec-0.35/encoded/1-17090940-replica-0x7b8e1d463a0fbc6fce05b31c5c30e605aa13efaca14a1f3ba991d33ea979b12b" http://ipfs-pinner:3001/upload; + curl -F "filedata=@/app/test-data/codec-0.35/encoded/1-17090960-replica-0xc95d44182ee006e79f1352ef32664210f383baa016988d5ab2fd950b52bf22ff" http://ipfs-pinner:3001/upload; echo Test bsp files uploaded!; cd /app; MIX_ENV=docker mix test --trace --slowest 10; diff --git a/docker-compose-mbase.yml b/docker-compose-mbase.yml index 5af00db6..c9e59159 100644 --- a/docker-compose-mbase.yml +++ b/docker-compose-mbase.yml @@ -1,3 +1,7 @@ +version: '3' +# runs the entire rudder pipeline with all supporting services (including rudder) in docker +# set .env such that all services in docker are talking to each other only + services: ipfs-pinner: image: "us-docker.pkg.dev/covalent-project/network/ipfs-pinner:stable" @@ -9,14 +13,14 @@ services: "autoheal": "true" expose: - "4001:4001" - - "3000:3000" + - "3001:3001" environment: - WEB3_JWT=${WEB3_JWT} networks: - cqt-net ports: - "4001:4001" - - "3000:3000" + - "3001:3001" evm-server: image: "us-docker.pkg.dev/covalent-project/network/evm-server:stable" @@ -62,6 +66,8 @@ services: - IPFS_PINNER_URL=${IPFS_PINNER_URL} networks: - cqt-net + ports: + - "9568:9568" autoheal: image: willfarrell/autoheal diff --git a/docker-compose-mbeam.yml b/docker-compose-mbeam.yml index 73a10f38..3379de67 100644 --- a/docker-compose-mbeam.yml +++ b/docker-compose-mbeam.yml @@ -12,14 +12,14 @@ services: "autoheal": "true" expose: - "4001:4001" - - "3000:3000" + - "3001:3001" environment: - WEB3_JWT=${WEB3_JWT} networks: - cqt-net ports: - "4001:4001" - - "3000:3000" + - "3001:3001" evm-server: image: "us-docker.pkg.dev/covalent-project/network/evm-server:stable" @@ -65,6 +65,8 @@ services: - IPFS_PINNER_URL=${IPFS_PINNER_URL} networks: - cqt-net + ports: + - "9568:9568" autoheal: image: willfarrell/autoheal diff --git a/docs/ARCH.md b/docs/ARCH.md index 653ed8c8..3a203aff 100644 --- a/docs/ARCH.md +++ b/docs/ARCH.md @@ -147,7 +147,7 @@ That will lead to the corresponding logs: Once the block results have been produced they need to be proved and uploaded. This ideally happens atomically for rudder. -Below is an example of how to interact with block result uploader that speaks to `ipfs-pinner` available with `export IPFS_PINNER_URL="http://127.0.0.1:3000"`. The file is directly uploaded to IPFS using the wrapped local IPFS node. +Below is an example of how to interact with block result uploader that speaks to `ipfs-pinner` available with `export IPFS_PINNER_URL="http://127.0.0.1:3001"`. The file is directly uploaded to IPFS using the wrapped local IPFS node. ```elixir file_path = Path.expand(Path.absname(Path.relative_to_cwd("test-data/temp2.txt"))) diff --git a/docs/development.md b/docs/development.md index 85614a79..331b355d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -39,7 +39,7 @@ Add the env vars to a .env file as below. Ask your node operator about these if ```bash export BLOCK_RESULT_OPERATOR_PRIVATE_KEY=block-result-operator-private-key-without-0x-prefix export NODE_ETHEREUM_MAINNET="https://moonbeam-alphanet.web3.covalenthq.com/alphanet/direct-rpc" -export IPFS_PINNER_URL="http://ipfs-pinner:3000" +export IPFS_PINNER_URL="http://ipfs-pinner:3001" export EVM_SERVER_URL="http://evm-server:3002" export WEB3_JWT="****" ``` diff --git a/docs/grafana.png b/docs/grafana.png new file mode 100644 index 00000000..223ea963 Binary files /dev/null and b/docs/grafana.png differ diff --git a/docs/metrics.md b/docs/metrics.md index 16aac87a..0abbe344 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -1,8 +1,111 @@ -# Metrics collection and reporting +# Metrics Collection and Reporting -`rudder` enabled metrics collection via `--metrics` flag. A metrics server can be enabled (by `--metrics.addr` and `--metrics.port`). The metrics are served in two formats: +`rudder` is proactively enabled with metrics collection via prometheus. -- `/debug/metrics`: json representation of expvars and go-metrics -- `/debug/metrics/prometheus`: same metrics as above but in prometheus format +## Config -Monitoring can be setup (for example) by plugging the endpoint serving in prometheus-format into influxdb, which is plugged into grafana. +Install Prometheus + +* Edit `/opt/homebrew/etc/prometheus.yml` for mac/m1. +or +* Edit `/usr/local/etc/prometheus.yml` for linux/x86. + +Add the config for prometheus to pick up exported [rudder telemetry metrics](../lib/rudder/metrics/prometheus.yml). + +Restart your prometheus server + +```bash +brew services restart prometheus +``` + +Monitoring can be setup (for example) by plugging the endpoint serving in prometheus-format into a grafana plugin, which can be viewed in grafana - sliced and diced further as per need per metric. + +## Metrics + +The following metrics captured from rudder are exported with `/metrics` endpoint via prometheus. + +```elixir +# TYPE rudder_events_rudder_pipeline_success_duration gauge +rudder_events_rudder_pipeline_success_duration{operation="pipeline_success",table="rudder_metrics"} 0.004265 +# TYPE rudder_events_rudder_pipeline_success_count counter +rudder_events_rudder_pipeline_success_count{operation="pipeline_success",table="rudder_metrics"} 4 +# TYPE rudder_events_journal_fetch_items_duration gauge +rudder_events_journal_fetch_items_duration{operation="fetch_items",table="journal_metrics"} 1.2e-5 +# TYPE rudder_events_journal_fetch_items_count counter +rudder_events_journal_fetch_items_count{operation="fetch_items",table="journal_metrics"} 1 +# TYPE rudder_events_journal_fetch_last_duration gauge +rudder_events_journal_fetch_last_duration{operation="fetch_last",table="journal_metrics"} 3.6e-5 +# TYPE rudder_events_journal_fetch_last_count counter +rudder_events_journal_fetch_last_count{operation="fetch_last",table="journal_metrics"} 1 +# TYPE rudder_events_brp_proof_duration gauge +rudder_events_brp_proof_duration{operation="proof",table="brp_metrics"} 6.259999999999999e-4 +# TYPE rudder_events_brp_proof_count counter +rudder_events_brp_proof_count{operation="proof",table="brp_metrics"} 4 +# TYPE rudder_events_brp_upload_success_duration gauge +rudder_events_brp_upload_success_duration{operation="upload_success",table="brp_metrics"} 0.0023769999999999998 +# TYPE rudder_events_brp_upload_success_count counter +rudder_events_brp_upload_success_count{operation="upload_success",table="brp_metrics"} 4 +# TYPE rudder_events_bsp_execute_duration gauge +rudder_events_bsp_execute_duration{operation="execute",table="bsp_metrics"} 2.1799999999999999e-4 +# TYPE rudder_events_bsp_execute_count counter +rudder_events_bsp_execute_count{operation="execute",table="bsp_metrics"} 4 +# TYPE rudder_events_bsp_decode_duration gauge +rudder_events_bsp_decode_duration{operation="decode",table="bsp_metrics"} 0.0 +# TYPE rudder_events_bsp_decode_count counter +rudder_events_bsp_decode_count{operation="decode",table="bsp_metrics"} 4 +# TYPE rudder_events_ipfs_fetch_duration gauge +rudder_events_ipfs_fetch_duration{operation="fetch",table="ipfs_metrics"} 0.001588 +# TYPE rudder_events_ipfs_fetch_count counter +rudder_events_ipfs_fetch_count{operation="fetch",table="ipfs_metrics"} 4 +# TYPE rudder_events_ipfs_pin_duration gauge +rudder_events_ipfs_pin_duration{operation="pin",table="ipfs_metrics"} 0.00174 +# TYPE rudder_events_ipfs_pin_count counter +rudder_events_ipfs_pin_count{operation="pin",table="ipfs_metrics"} 4 +``` + +## API + +View exported gauges and counters using prometheus at the endpoint -> . + +Create graphs using prometheus at the endpoint -> . + +View timeseries and add alerting with grafana at the endpoint -> . + +Docker containers automatically export to this endpoint as well via exposed ports and port forwarding. + +## Graph + +Observe live the gauge time series graphs with plots for example with metrics for `pipeline_success` and `ipfs_fetch` -> + +![Observe](./prometheus.png) + +## Monitor & Alert + +For monitoring and alerting we advice using [Grafana (in conjunction with the aggregated prometheus metrics)](https://grafana.com/docs/grafana/latest/getting-started/get-started-grafana-prometheus/). + +Install and start Grafana + +```bash +brew install grafana +brew services start grafana +``` + +Ensure Grafana (default port 3000) and Prometheus (default port 9090) have started. + +```bash +$ brew services list +Name Status User File +grafana started user ~/Library/LaunchAgents/homebrew.mxcl.grafana.plist +prometheus started user ~/Library/LaunchAgents/homebrew.mxcl.prometheus.plist +``` + +Login to your Grafana dashboard -> http://localhost:3000/. + +Make sure prometheus is added as a data source -> http://localhost:3000/datasources with the default values for prometheus. Click on [Explore](http://localhost:3000/explore?left=%7B%22datasource%22:%22lVZwdz8Vz%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22lVZwdz8Vz%22%7D%7D%5D,%22range%22:%7B%22from%22:%22now-1h%22,%22to%22:%22now%22%7D%7D&orgId=1). + +Select the metrics and time-series data to view from the dropdown with "Select Metric". +Below is an example of three selections `rudder_events_brp_upload_success_duration`, `rudder_events_rudder_pipeline_success_duration`, `rudder_events_ipfs_fetch_duration`. + +This can directly be viewed [here](http://localhost:3000/explore?left=%7B%22datasource%22:%22lVZwdz8Vz%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22lVZwdz8Vz%22%7D,%22editorMode%22:%22builder%22,%22expr%22:%22rudder_events_brp_upload_success_duration%22,%22legendFormat%22:%22__auto%22,%22range%22:true,%22instant%22:true%7D,%7B%22refId%22:%22B%22,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22lVZwdz8Vz%22%7D,%22editorMode%22:%22builder%22,%22expr%22:%22rudder_events_rudder_pipeline_success_duration%22,%22legendFormat%22:%22__auto%22,%22range%22:true,%22instant%22:true%7D,%7B%22refId%22:%22C%22,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22lVZwdz8Vz%22%7D,%22editorMode%22:%22builder%22,%22expr%22:%22rudder_events_ipfs_fetch_duration%22,%22legendFormat%22:%22__auto%22,%22range%22:true,%22instant%22:true%7D%5D,%22range%22:%7B%22from%22:%22now-15m%22,%22to%22:%22now%22%7D%7D&orgId=1). You can also add operations on the exported data with aggregations like `sum` and range functions like `delta` etc as seen below. + +![grafana](./grafana.png) diff --git a/docs/prometheus.png b/docs/prometheus.png new file mode 100644 index 00000000..d4fc27e1 Binary files /dev/null and b/docs/prometheus.png differ diff --git a/docs/rudder-compose.service b/docs/rudder-compose.service index c30d5125..393376ff 100644 --- a/docs/rudder-compose.service +++ b/docs/rudder-compose.service @@ -9,7 +9,7 @@ Group=blockchain Environment=HOME=/home/blockchain/tmp Environment="BLOCK_RESULT_OPERATOR_PRIVATE_KEY=ba3193ff8df497b5369f0d5c92fe443efd7936ab910084b8d4e1d510f05da1b2" Environment="NODE_ETHEREUM_MAINNET=https://moonbeam.web3.com/alphanet/rpc" -Environment="IPFS_PINNER_URL=http://ipfs-pinner:3000" +Environment="IPFS_PINNER_URL=http://ipfs-pinner:3001" Environment="EVM_SERVER_URL=http://evm-server:3002" Environment="WEB3_JWT=iI91eXzhJUCyIJIINC6bsJciVkOIIpniGRc5.UiNjXLQJJYdYE2NfXdN0ziG5zWFeIW3EpjygiLOol1caizyZIz5WkMTiMMzT1MAZNM3ITmCQGcLNbeJOMQb43JOiwQ3TQMJz2zTMWECOnsIQhWdNoi6ZipYtc2XOMixAW3JQR4cwlTNkYgJDmhjiJQFYkQ3ciUbWOR.2Vx73BD3BWoD5FG6alOp7foK8krI7Akysr5lVbhP4Bu" Type=simple diff --git a/lib/rudder/metrics/prometheus.yml b/lib/rudder/metrics/prometheus.yml new file mode 100644 index 00000000..33870739 --- /dev/null +++ b/lib/rudder/metrics/prometheus.yml @@ -0,0 +1,10 @@ +global: + scrape_interval: 15s + +scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090"] + - job_name: "telemetry_metrics_prometheus" + static_configs: + - targets: ["localhost:9568"] \ No newline at end of file diff --git a/lib/rudder/metrics/telemetry.ex b/lib/rudder/metrics/telemetry.ex index 6dc06c73..3428b3ba 100644 --- a/lib/rudder/metrics/telemetry.ex +++ b/lib/rudder/metrics/telemetry.ex @@ -11,7 +11,7 @@ defmodule Rudder.Telemetry do def init(_arg) do metrics = [ # event_emitting (all available metrics for any event) - counter("rudder.events.emit.duration", + counter("rudder.events.emit.count", tags: [:table, :operation] ), last_value("rudder.events.emit.duration", @@ -33,7 +33,7 @@ defmodule Rudder.Telemetry do ), # ipfs_pinning - counter("rudder.events.ipfs_pin.duration", + counter("rudder.events.ipfs_pin.count", tags: [:table, :operation] ), last_value("rudder.events.ipfs_pin.duration", @@ -50,7 +50,7 @@ defmodule Rudder.Telemetry do ), # ipfs_fetching - counter("rudder.events.ipfs_fetch.duration", + counter("rudder.events.ipfs_fetch.count", tags: [:table, :operation] ), last_value("rudder.events.ipfs_fetch.duration", @@ -67,7 +67,7 @@ defmodule Rudder.Telemetry do ), # bsp_decoding - counter("rudder.events.bsp_decode.duration", + counter("rudder.events.bsp_decode.count", tags: [:table, :operation] ), last_value("rudder.events.bsp_decode.duration", @@ -84,7 +84,7 @@ defmodule Rudder.Telemetry do ), # bsp_executing - counter("rudder.events.bsp_execute.duration", + counter("rudder.events.bsp_execute.count", tags: [:table, :operation] ), last_value("rudder.events.bsp_execute.duration", @@ -101,7 +101,7 @@ defmodule Rudder.Telemetry do ), # brp_uploading - counter("rudder.events.brp_upload_success.duration", + counter("rudder.events.brp_upload_success.count", tags: [:table, :operation] ), last_value("rudder.events.brp_upload_success.duration", @@ -116,7 +116,7 @@ defmodule Rudder.Telemetry do unit: {:native, :millisecond}, tags: [:table, :operation] ), - counter("rudder.events.brp_upload_failure.duration", + counter("rudder.events.brp_upload_failure.count", tags: [:table, :operation] ), last_value("rudder.events.brp_upload_failure.duration", @@ -133,7 +133,7 @@ defmodule Rudder.Telemetry do ), # brp_proofing - counter("rudder.events.brp_proof.duration", + counter("rudder.events.brp_proof.count", tags: [:table, :operation] ), last_value("rudder.events.brp_proof.duration", @@ -150,7 +150,7 @@ defmodule Rudder.Telemetry do ), # journal_fetching - counter("rudder.events.journal_fetch_last.duration", + counter("rudder.events.journal_fetch_last.count", tags: [:table, :operation] ), last_value("rudder.events.journal_fetch_last.duration", @@ -165,7 +165,7 @@ defmodule Rudder.Telemetry do unit: {:native, :millisecond}, tags: [:table, :operation] ), - counter("rudder.events.journal_fetch_items.duration", + counter("rudder.events.journal_fetch_items.count", tags: [:table, :operation] ), last_value("rudder.events.journal_fetch_items.duration", @@ -182,7 +182,7 @@ defmodule Rudder.Telemetry do ), # rudder_pipelining - counter("rudder.events.rudder_pipeline_success.duration", + counter("rudder.events.rudder_pipeline_success.count", tags: [:table, :operation] ), last_value("rudder.events.rudder_pipeline_success.duration", @@ -197,7 +197,7 @@ defmodule Rudder.Telemetry do unit: {:native, :millisecond}, tags: [:table, :operation] ), - counter("rudder.events.rudder_pipeline_failure.duration", + counter("rudder.events.rudder_pipeline_failure.count", tags: [:table, :operation] ), last_value("rudder.events.rudder_pipeline_failure.duration", @@ -215,7 +215,8 @@ defmodule Rudder.Telemetry do ] children = [ - {Rudder.Telemetry.CustomReporter, metrics: metrics} + {Rudder.Telemetry.CustomReporter, metrics: metrics}, + {TelemetryMetricsPrometheus, metrics: metrics} ] Supervisor.init(children, strategy: :one_for_one) diff --git a/mix.exs b/mix.exs index ddcc7a31..62e2d28e 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Rudder.MixProject do def project do [ app: :rudder, - version: "0.2.8", + version: "0.2.9", elixir: "~> 1.14.3", start_permanent: Mix.env() == :prod, deps: deps() @@ -75,6 +75,8 @@ defmodule Rudder.MixProject do # tracing metrics {:telemetry, "~> 1.2.1", override: true}, {:telemetry_metrics, "~> 0.3.0"}, + {:telemetry_metrics_prometheus, "~> 0.3.1"}, + {:telemetry_metrics_prometheus_core, "~>0.2.2"}, # utils {:briefly, "~> 0.4.1"} diff --git a/mix.lock b/mix.lock index 5db40b07..93bbd8e6 100644 --- a/mix.lock +++ b/mix.lock @@ -60,6 +60,8 @@ "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, "telemetry_metrics": {:hex, :telemetry_metrics, "0.3.1", "799e7a3e40ebe740df265346dd1f5ff3e3c3e285f1436cd51fc8ac3b2bb7a772", [:mix], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2a1e01e752d9fd2afa70c8de4b0309535d8071a34ae329e4d68980a9bd694bfa"}, + "telemetry_metrics_prometheus": {:hex, :telemetry_metrics_prometheus, "0.3.1", "ee4304aafb8fa34bc54186707b0f882030b762d4a8d393af1eccd12c2eca104b", [:mix], [{:plug_cowboy, "~> 2.1", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:telemetry_metrics_prometheus_core, "~> 0.2", [hex: :telemetry_metrics_prometheus_core, repo: "hexpm", optional: false]}], "hexpm", "e067bd280ae8d5ce82cc02515c5a6e201a7dd7939542a409d9ed63fb3d60f10c"}, + "telemetry_metrics_prometheus_core": {:hex, :telemetry_metrics_prometheus_core, "0.2.2", "c75a99f68a03dd2a4061cd333e3c4728971fada798c2e096f6bca067e15b402c", [:mix], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.3", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "02c1f738cd0b5c75148daecb28282ccabb806a49b717df88935a48502bb257d6"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, "websockex": {:hex, :websockex, "0.4.3", "92b7905769c79c6480c02daacaca2ddd49de936d912976a4d3c923723b647bf0", [:mix], [], "hexpm", "95f2e7072b85a3a4cc385602d42115b73ce0b74a9121d0d6dbbf557645ac53e4"}, }