Skip to content

Add prometheus and grafana make commands for local environment#12240

Merged
fosterseth merged 4 commits into
ansible:develfrom
fosterseth:make_prometheus_grafana
Jun 1, 2022
Merged

Add prometheus and grafana make commands for local environment#12240
fosterseth merged 4 commits into
ansible:develfrom
fosterseth:make_prometheus_grafana

Conversation

@fosterseth

Copy link
Copy Markdown
Member
SUMMARY

make prometheus and make grafana will start local docker containers that integrate with a running awx instance.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • API
AWX VERSION
awx: 21.0.1.dev107+gb03dbc68c2

@fosterseth fosterseth force-pushed the make_prometheus_grafana branch from 0b171a3 to ae805e2 Compare May 16, 2022 18:51
@fosterseth fosterseth force-pushed the make_prometheus_grafana branch 2 times, most recently from 1f3b6ca to 568f93c Compare May 16, 2022 21:38
{% if control_plane_node_count|int > 1 %}
haproxy:
image: haproxy
image: haproxy:2.3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like bleed over from another open PR you have.


1. Change the `username` and `password` in `tools/prometheus/prometheus.yml`. You can also change the scrape interval.
2. (optional) if you are in cluster environment, you can change the target to `haproxy:8043` so that the incoming prometheus requests go through the load balancer. Leaving it set to `awx1` also works.
3. run `make prometheus`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like, in a new terminal tab or something?

"refId": "B"
}
],
"title": "jobs running pending",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the title confuses me somewhat

Comment thread tools/docker-compose/README.md Outdated
Prometheus is a metrics collecting tool, and we support prometheus formatted data at the `api/v2/metrics` endpoint.

1. Change the `username` and `password` in `tools/prometheus/prometheus.yml`. You can also change the scrape interval.
2. (optional) if you are in cluster environment, you can change the target to `haproxy:8043` so that the incoming prometheus requests go through the load balancer. Leaving it set to `awx1` also works.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these new tools for dev testing only or are they actually intended to be run against something like a cluster?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are leaving this in here you are in a clustered environment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intended for dev / testing usage

1. Change the `username` and `password` in `tools/prometheus/prometheus.yml`. You can also change the scrape interval.
2. (optional) if you are in cluster environment, you can change the target to `haproxy:8043` so that the incoming prometheus requests go through the load balancer. Leaving it set to `awx1` also works.
3. run `make prometheus`
4. navigate to `http://localhost:9090/targets` and check that the metrics endpoint State is Up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the metrics API endpoint or an endpoint under prometheus (this is right after the prometheus URL).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would this be "localhost" or would that depend on your installation? In other places in this document we talk about "container_reference" and how one might get that.

Comment thread Makefile
Comment on lines 531 to +537
prometheus:
docker run -u0 --net=tools_default --link=`docker ps | egrep -o "tools_awx(_run)?_([^ ]+)?"`:awxweb --volume `pwd`/tools/prometheus:/prometheus --name prometheus -d -p 0.0.0.0:9090:9090 prom/prometheus --web.enable-lifecycle --config.file=/prometheus/prometheus.yml
docker volume create prometheus
docker run -d --rm --net=_sources_default --link=awx_1:awx1 --volume prometheus-storage:/prometheus --volume `pwd`/tools/prometheus:/etc/prometheus --name prometheus -p 9090:9090 prom/prometheus

grafana:
docker volume create grafana
docker run -d --rm --net=_sources_default --volume grafana-storage:/var/lib/grafana --volume `pwd`/tools/grafana:/etc/grafana/provisioning --name grafana -p 3001:3000 grafana/grafana-enterprise

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of individual targets should we move these into the model like we did for LDAP/SPLUNK/etc where you would do something like: GRAFANA=True make docker-compose?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would ultimately prefer this, but I think it makes sense to merge it with the current scheme and work on this later.

The biggest pain point for me of the current approach is that it doesn't show startup logs, and integrating it into docker-compose would fix that.


- job_name: 'awx'
static_configs:
- targets: ['awx1:8043'] # or haproxy:8043 in cluster env

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be awx1 or tools_awx_1?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prometheus expects a real dns name here, so underscores aren't allowed.

that is why I need to alias awx_1 to awx1 when starting the prometheus container

@AlanCoding

Copy link
Copy Markdown
Member

Link candidate fix AlanCoding@12c4807

@fosterseth fosterseth force-pushed the make_prometheus_grafana branch from 8579cf8 to 6f68f3c Compare May 31, 2022 21:07

@kdelee kdelee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me out of the box now!
Screenshot from 2022-05-31 19-13-40

This is after deleting all containers/volumes and starting fresh

Comment thread Makefile
prometheus:
docker run -u0 --net=tools_default --link=`docker ps | egrep -o "tools_awx(_run)?_([^ ]+)?"`:awxweb --volume `pwd`/tools/prometheus:/prometheus --name prometheus -d -p 0.0.0.0:9090:9090 prom/prometheus --web.enable-lifecycle --config.file=/prometheus/prometheus.yml
docker volume create prometheus
docker run -d --rm --net=_sources_default --link=awx_1:awx1 --volume prometheus-storage:/prometheus --volume `pwd`/tools/prometheus:/etc/prometheus --name prometheus -p 9090:9090 prom/prometheus

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder for later - we need a target for something like

docker volume rm prometheus prometheus-storage grafana grafana-storage

@fosterseth fosterseth merged commit b548ad2 into ansible:devel Jun 1, 2022
@fosterseth fosterseth deleted the make_prometheus_grafana branch March 11, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants