{"id":22007738,"url":"https://github.com/rubberduck203/ex_prometheus_logger","last_synced_at":"2025-07-04T14:38:56.213Z","repository":{"id":83178184,"uuid":"156634434","full_name":"rubberduck203/ex_prometheus_logger","owner":"rubberduck203","description":"Elixir Logger Backend for Prometheus","archived":false,"fork":false,"pushed_at":"2018-11-10T16:05:10.000Z","size":362,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T13:52:39.996Z","etag":null,"topics":["elixir","error-monitoring","log-metrics","log-monitoring","prometheus"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubberduck203.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-08T01:49:22.000Z","updated_at":"2018-11-10T16:05:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"38ddc71a-01e9-4707-8a03-cbfd8fb66dee","html_url":"https://github.com/rubberduck203/ex_prometheus_logger","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubberduck203%2Fex_prometheus_logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubberduck203%2Fex_prometheus_logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubberduck203%2Fex_prometheus_logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubberduck203%2Fex_prometheus_logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubberduck203","download_url":"https://codeload.github.com/rubberduck203/ex_prometheus_logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066715,"owners_count":20555431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","error-monitoring","log-metrics","log-monitoring","prometheus"],"created_at":"2024-11-30T01:29:07.521Z","updated_at":"2025-03-23T07:15:39.295Z","avatar_url":"https://github.com/rubberduck203.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ExPrometheusLogger\n\nExPrometheusLogger is a [custom Elixir logger backend](https://hexdocs.pm/logger/Logger.html#module-custom-backends).\nIt creates counters and increments them on logging events, providing easy insight into the number of warning \u0026 errors occuring in your applications.\n\n![`ex_logger`: Rising counts of errors and warnings](img/count.png)\n\n![`rate(ex_logger[30s])`: Rate of increase per second of warnings and errors](img/rate.png)\n\n## Installation\n\n### mix.exs\n\n```elixir\ndef deps do\n  [\n    {:prometheus_logger, git: \"https://github.com/rubberduck203/ex_prometheus_logger.git\", tag: \"0.1.1\"},\n  ]\n```\n\n\u003c!--\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `prometheus_logger` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:prometheus_logger, \"~\u003e 0.1.1\"}\n  ]\nend\n```\n--\u003e\n\n### Configuration\n\nJust add the logger backend to your config\n\n#### config.exs\n\n```elixir\nconfig :logger,\n  backends: [:console, Logger.Backends.Prometheus]\n```\n\nand ensure that `:prometheus` is started before `:logger`.\n\n#### mix.exs\n\n```elixir\ndef application do\n  [\n    # :prometheus *must* be started before :logger\n    extra_applications: [:prometheus, :logger]\n  ]\nend\n```\n\nCurrently, the only supported configuration is the log level.\nIt defaults to `:warn`.\nSetting or changing the base logger level has no effect on ExPrometheusLogger's level.\n\n```\nconfig :logger, Logger.Backends.Prometheus,\n  level: :warn\n```\n\n\u003c!--\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/prometheus_logger](https://hexdocs.pm/prometheus_logger).\n--\u003e\n\n## Exposing Metrics\n\nExPrometheusLogger doesn't actually publish the metrics.\nIt just creates and increments [prometheus_ex counters](https://hexdocs.pm/prometheus_ex/Prometheus.Metric.Counter.html#content).\n\nIt's the user's responsibility to expose those metrics,\neither by [exposing a `/metrics` endpoint](https://medium.com/@brucepomeroy/publishing-metrics-to-prometheus-from-elixir-bb70efcd6ec1)\nor by using the [pushgateway](https://github.com/deadtrickster/prometheus-push).\n\nSee the [example](example/) directory for examples of how to use [pushgateway](example/pushgateway) and [Cowboy \u0026 Plug](example/cowboy) to publish the metrics.\n\n## Alerting\n\nThe logger backend uses a `counter` to collect the number of times different level logging events have occured.\nBecause this is a counter, to set up an alert, it us recommended to use the [`rate()`](https://prometheus.io/docs/prometheus/latest/querying/functions/#rate) function to calculate the rate at which errors/warnings are *increasing* over a period of time.\n\n```prometheus\nrate(\n  ex_logger{level=\"error\"}[1m]\n)\n```\n\nSee [example/rules.yml](example/rules.yml) for sample alerting rules.\n\nThere are times you may want to alert on a hard number of log messages.\nThat should be a relatively rare, but straight forward, use case.\n\n## Roadmap\n\n- [x] Provide examples for using\n   - [x] Pushgateway\n   - [x] Exposing a `/metrics` endpoint\n- [ ] Use pushgateway automatically if `:prometheus, :pushgateway` config is present in app env.\n- [ ] Publish on Hex\n- [ ] Publish docs\n- [ ] Travis CI build/release\n- [ ] Custom labels?\n- [ ] Take `:logger, :level` into consideration\n- [ ] Leverage logger meta-data?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubberduck203%2Fex_prometheus_logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubberduck203%2Fex_prometheus_logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubberduck203%2Fex_prometheus_logger/lists"}