Skip to content

Commit

Permalink
Merge pull request #340 from sstrigler/master
Browse files Browse the repository at this point in the history
mod_prometheus: use 'declare' rather than 'new' for histogram and counter  (#339)
  • Loading branch information
badlop authored Nov 6, 2024
2 parents 4e58ae9 + 769dbf0 commit a357f8a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions mod_prometheus/example/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ version: '3.7'
services:

prometheus:
network_mode: "host"
image: docker.io/prom/prometheus
container_name: prometheus
ports:
- "9090:9090"
volumes:
- prometheus-data:/prometheus
- ./prometheus.yml:/etc/prometheus/prometheus.yml
restart: always

grafana:
network_mode: "host"
image: docker.io/grafana/grafana-enterprise
container_name: grafana
ports:
- "3000:3000"
volumes:
- grafana-data:/var/lib/grafana
- ./grafana_defaults.ini:/usr/share/grafana/conf/defaults.ini
restart: always

volumes:
prometheus-data:
grafana-data:
6 changes: 3 additions & 3 deletions mod_prometheus/src/mod_prometheus.erl
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ handle_histogram(Name, HName, HistogramOpts, Host, Action, State) ->
InitArg = State#{name => HName, labels => LabelNames},
case Action of
subscribe ->
prometheus_histogram:new(
prometheus_histogram:declare(
[
{name, HName},
{buckets, maps:get(buckets, HistogramOpts, [1, 10, 100, 500, 750, 1000, 3000, 5000])},
Expand All @@ -377,7 +377,7 @@ handle_counter(Name, HName, CounterOpts, Host, Action, State) ->
InitArg = State#{name => HName, labels => LabelNames},
case Action of
subscribe ->
prometheus_counter:new(
prometheus_counter:declare(
[{name, HName}, {help, maps:get(help, CounterOpts, "No help")}, {labels, LabelNames}]
),
?INFO_MSG("Created new Prometheus counter for ~p with labels ~p", [HName, LabelNames]),
Expand Down Expand Up @@ -441,4 +441,4 @@ find_stanza_type([Arg | Args]) when is_tuple(Arg) ->
find_stanza_type([_ | Args]) ->
find_stanza_type(Args);
find_stanza_type([]) ->
unknown.
unknown.

0 comments on commit a357f8a

Please sign in to comment.