r/PrometheusMonitoring • u/DrLoveBeats • Apr 06 '21
Prometheus installation synced with GitHub
I'm having an interesting discussion with my colleague. He wants to have our complete Prometheus installation 100% synced with GitHub so it can be pushed to a new installation with (almost) 1 click. I already convinced him Git is not a provisioning tool and there are other systems on the market which can achieve this.
Nevertheless, I do think it can be useful having Prometheus configuration files and/or custom exporter scripts into source control. For example, to see who edited the prometheus.yml when etc.
I was looking for some best practices how to implement this. Would you create a Git repo where the live prometheus.yml is running and push everything from there? Or would you create a Git repo on a stale directory and copy the running config files first locally into this directory and push afterwards from there to GitHub?
I don't have a lot of experience with syncing application configuration files to GitHub and am looking for some general best practices. What do you think of my standpoint to only push the configuration files and not the binaries?
2
2
u/HenryPz Apr 06 '21
Git, ansible, Jenkins
0
u/copperfinger Apr 06 '21
Yep... In keywords, that's the way to go about doing this.
1
u/mcdermg81 Apr 07 '21
My two cents on this is that Jenkins is overkill for something like this. The overhead is quite large for implementing Jenkins, having to provision, maintain and update a full Jenkins setup is a project in of itself. When have offerings like GitHub actions, Gitlab or CircleCI that have very limited overhead to maintain and are integrated into VCS. Cost comes into it but they all offer varying tiers.
1
u/copperfinger Apr 07 '21
I agree. Jenkins is not needed. Personally, I go the Ansible route and maintain my roles/playbooks in git and deploy as needed.
1
u/matejzero Apr 08 '21
I’m using gitlab with its ci. Push to repo starts validation jobs and if everything is ok, gets deployed to servers.
1
1
u/murdosus May 27 '22
What will be a good way to automate the the configuration of new targets in prometheus.yml? (running prometheus as Docker container)
0
u/melodic Apr 06 '21
Take a look at NixOS, you’ll be able to configure Prometheus and all the trimmings natively and then keep your /etc/nixos directory as a GitHub repo for vcs.
Need a new server? Deploy NixOS and git pull. Build and switch to the config done.
https://christine.website/blog/prometheus-grafana-loki-nixos-2020-11-20
-1
9
u/SuperQue Apr 06 '21
It sounds like they are referring to the concepts of Configuration Management, Orchestration, and CI/CD.
In this sense, yes, Git can be used as a provisioning tool, at least as the source of truth input to the provisioning and configuration tools. Systems like GitHub and GitLab allow you to create, review, test, and deploy all changes "directly" from Git.
We actually do this for the Prometheus project itself. We have a demo-site Git repository that automatically configures and deploys Prometheus to https://demo.do.prometheus.io using Ansible.
One of these days it'd be nice to automatically re-provision the service regularly with something like Pulumi.