line / promgen

Promgen is a configuration file generator for Prometheus
https://line.github.io/promgen/
MIT License
1.06k stars 150 forks source link

Promgen Worker #58

Closed hmmxp closed 5 years ago

hmmxp commented 6 years ago

Dear All,

Currently i have created an installation guide for Promgen Web on CentOS 7, how can i install and configure Promgen Worker On CentOS 7?

seoester commented 6 years ago

The preparation and installation required for the worker are the same as for the web app.

Then you register and start like this:

# Register prometheus server
# Syntax: promgen register <shard name> <prometheus host> <prometheus port>
promgen register default localhost 9090
# Start worker
# Syntax: celery -A promgen worker -l <log level> -Q <queues>
celery -A promgen worker -l info -Q localhost

The worker needs to subscribe to the queue with the host name of the prometheus server.

You can also have a look at #57, it includes documentation on how to setup the web app and the worker using docker.

hmmxp commented 6 years ago

i believe the above is for push model if promgen and promethues is installed on the same server.

But my Prometheus and promgen is on different server, how can i configure pull model?

Update:

I saw this article https://github.com/kfdm/promgen/blob/5baa8fe44e6f5bac78f4f33989990d0101c5b40b/docs/worker.rst

But how should i register my Prometheus server to promgen? Or are there any missing steps?

kfdm commented 6 years ago

The celery worker is installed the same way as the web app and as long as they can reach the same database and redis instance, it doesn't matter if the web app and workers are on different servers.

Apparently I forgot to merge some docs updates but you should be able to see some illustrations here https://github.com/line/promgen/pull/46/files I'll try to go through the PRs on Monday.

hmmxp commented 6 years ago

Dear Paul & Seoster,

Will await the documents and finish testing in my linux environment and if i have spare time will test on docker

My other question is are the below run once:

Register prometheus server

Syntax: promgen register

promgen register default localhost 9090

Start worker

Syntax: celery -A promgen worker -l -Q

celery -A promgen worker -l info -Q localhost

As i am running promgen in a virtual env, and if the above is run once and upon my server reboot it is still in effect?

thank you all for the wonderful job

kfdm commented 6 years ago

Correct. Those commands register the worker in Promgen's database so the data is saved between reboots and anything else :)

The worker flags you need to add to your startup command so that it knows which queue to run from.

hmmxp commented 6 years ago

Dear Paul,

If i am running uWSGI to launch the application where should i add the worker flag?

kfdm commented 6 years ago

uWSGI would be used to run the Promgen worker, so there are no worker flags required.

Something like systemd or another process manager would run the worker on the same node as Prometheus. I use something like this when deployed from Ansible

[Unit]
Description=Daemon for Celery
After=network.target

[Service]
Type=simple
ExecStart={{ promgen_virutalenv }}/bin/celery -A promgen worker -l info --queues {{ ansible_host }}
Restart=on-failure
User=prometheus

[Install]
WantedBy=multi-user.target
hmmxp commented 6 years ago

Dear Paul,

Noted on this let me test it out and feedback and update the document as needed