Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create example Grafana dashboard for Prometheus metrics #74

Open
colindean opened this issue Dec 29, 2021 · 18 comments
Open

Create example Grafana dashboard for Prometheus metrics #74

colindean opened this issue Dec 29, 2021 · 18 comments
Assignees
Labels
enhancement New feature or request

Comments

@colindean
Copy link
Contributor

I'm working on this now but I'm pretty new to Grafana so I'm using this as an opportunity to learn!

@cooperspencer cooperspencer added the enhancement New feature or request label Dec 29, 2021
@michaelrommel
Copy link

Hi,

I installed this over the weekend and - at least for me - I could not wrap my head around, how the implemented metrics could be graphed in a sensible way. The metrics for a regular backup of 1 repository look like this:

# HELP gickup_destinations The count of destinations configured                                                                                                                                
# TYPE gickup_destinations gauge                                                                                                                                                               
gickup_destinations 1                                                                                                                                                                          
# HELP gickup_destinations_complete The count of destination to which a backup was written                                                                                                     
# TYPE gickup_destinations_complete counter                                                                                                                                                    
gickup_destinations_complete{destination_type="local"} 2                                                                                                                                       
# HELP gickup_job_duration The duration of scheduled jobs started since process startup                                                                                                        
# TYPE gickup_job_duration summary                                                                                                                                                             
gickup_job_duration_sum 1.9519866019999998                                                                                                                                                     
gickup_job_duration_count 2                                                                                                                                                                    
# HELP gickup_jobs_complete The count of scheduled jobs completed since process startup                                                                                                        
# TYPE gickup_jobs_complete counter                                                                                                                                                            
gickup_jobs_complete 2                                                                                                                                                                         
# HELP gickup_jobs_started The count of scheduled jobs started since process startup                                                                                                           
# TYPE gickup_jobs_started counter                                                                                                                                                             
gickup_jobs_started 2                                                                                                                                                                          
# HELP gickup_repos_discovered The count of sources configured                                                                                                                                 
# TYPE gickup_repos_discovered gauge                                                                                                                                                           
gickup_repos_discovered{config_number="0",source_name="bitbucket"} 0                                                                                                                           
gickup_repos_discovered{config_number="0",source_name="gitea"} 1                                                                                                                               
gickup_repos_discovered{config_number="0",source_name="github"} 0                                                                                                                              
gickup_repos_discovered{config_number="0",source_name="gitlab"} 0                                                                                                                              
gickup_repos_discovered{config_number="0",source_name="gogs"} 0                                                                                                                                
gickup_repos_discovered{config_number="0",source_name="onedev"} 0                                                                                                                              
gickup_repos_discovered{config_number="0",source_name="sourcehut"} 0                                                                                                                           
gickup_repos_discovered{config_number="0",source_name="whatever"} 0                                                                                                                            
# HELP gickup_sources The count of sources configured                                                                                                                                          
# TYPE gickup_sources gauge                                                                                                                                                                    
gickup_sources 1                                                                                                                                                                               
# HELP gickup_sources_complete The count of source backups completed                                                                                                                           
# TYPE gickup_sources_complete counter                                                                                                                                                         
gickup_sources_complete{source_name="squeezelite"} 2        

I would like to get some kind of alert, if a repo could not successfully be backed up during the last run. Since the runs are in large intervals, any kind of bar or line graph may not bring a lot of value. E.g. I tried just to graph counters, but since they increment in 6 hour intervals and usually my dashboard show more like the last 1-3 hours, I cannot tell, whether there was a successful backup i.e. a step in the graph. Making rate queries do also not make sense for those intervals.

I guess, what I am looking for is some kind of Gauge with successful (or failed) number of jobs the last time the "cron" job ran.
Then we could show a gauge with its max. value being the sources configured and the metric being the successful ones.
This could be an immediate indicator, whether there is something wrong.

I am not a Go programmer, so I cannot really help here (but I will have a look later), but I wanted to just share the experience.

Thanks for the module anyhow, it is very reassuring to have an additional automated copy of all repos from an own Gitea instance!! Thanks a lot!!

Michael.

@michaelrommel
Copy link

Hm, looking into the code, I think there is not enough error handling present, but I am not a Go knowledgeable person. I believe, usually one would return a status code from the backup routine, like from the Gitea.Backup() function. But there are only Fatal errors there, which leads then to the whole container terminating. The other non-fatal error would be when the repo no longer exists or cannot be opened. This error is then handled by just skipping over it, but it does not return a true/false/err object back to the caller. I believe the above idea would need a larger modification. But that is just my thinking after looking at the source for 15 minutes or so…

@cooperspencer
Copy link
Owner

Hi,
I actually plan to change the error handling to allow something like this.
I will implement this in the near future.

@michaelrommel
Copy link

Hi,
I actually plan to change the error handling to allow something like this.
I will implement this in the near future.

Wow, this would be perfect - thanks for the quick response! Depending on my health over the next days, maybe I find the time to learn more about Go's exception handling and have a go at it myself… At least as an example for gitea…

Thanks for this nice piece of software! Cheers,

Michael.

@cooperspencer
Copy link
Owner

@michaelrommel I took a quick look today and changed the local module a bit, so now you can see if a repository was cloned successfully and how long that particular clone took. Is that sufficient for you?

# HELP gickup_repo_success See if backup was successful
# TYPE gickup_repo_success gauge
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="DataMining",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="airplane-docker",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="awesome-docker",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="awesome-git",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="bitnami-docker-phabricator",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="charly",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="check_yml_tests",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="config-rs",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="deb-get",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="docker-feather",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="docker-minecraft-server",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="docker-rethinkdb",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="docker-rygel",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="elasticsearch_indices",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="example_rest_server",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="gickup",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="gickup-blog",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="gickup-documentation",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="gluster_exporter",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="go-gitbucket",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="go-puppetdb",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="go-temp",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="gogs-container",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="gollum",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="gonduit",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="grok",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="grokbeat",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="grokky",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="helix",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="historian",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="install_nordvpn_solus",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="minebackup",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="neonbrainfuck",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="nonna",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="onedev",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="ow",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="paper-docker",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="pastella",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="phorge",type="local"} 1
gickup_repo_success{hoster="github.com",owner="cooperspencer",repository="purpur-docker",type="local"} 1
# HELP gickup_repo_time How long did the task take
# TYPE gickup_repo_time gauge
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="DataMining",type="local"} 1.49281488e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="airplane-docker",type="local"} 2.53478877e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="awesome-docker",type="local"} 1.88245254e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="awesome-git",type="local"} 1.53948641e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="bitnami-docker-phabricator",type="local"} 3.52677106e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="charly",type="local"} 1.5294233e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="check_yml_tests",type="local"} 1.70337602e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="config-rs",type="local"} 1.64435353e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="deb-get",type="local"} 1.51859035e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="docker-feather",type="local"} 1.52308043e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="docker-minecraft-server",type="local"} 1.64271671e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="docker-rethinkdb",type="local"} 1.50853102e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="docker-rygel",type="local"} 1.59130241e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="elasticsearch_indices",type="local"} 1.5885992e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="example_rest_server",type="local"} 1.541747e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="gickup",type="local"} 3.68554475e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="gickup-blog",type="local"} 1.76497794e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="gickup-documentation",type="local"} 1.5674122e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="gluster_exporter",type="local"} 1.54753169e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="go-gitbucket",type="local"} 1.62048073e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="go-puppetdb",type="local"} 1.65675763e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="go-temp",type="local"} 1.75271107e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="gogs-container",type="local"} 3.84430453e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="gollum",type="local"} 1.76521584e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="gonduit",type="local"} 1.57995173e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="grok",type="local"} 1.44477713e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="grokbeat",type="local"} 1.6896141e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="grokky",type="local"} 1.40839852e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="helix",type="local"} 1.68429242e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="historian",type="local"} 1.61749611e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="install_nordvpn_solus",type="local"} 1.91043175e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="minebackup",type="local"} 1.75688514e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="neonbrainfuck",type="local"} 2.79344725e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="nonna",type="local"} 2.01465427e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="onedev",type="local"} 1.51673375e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="ow",type="local"} 1.69696166e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="paper-docker",type="local"} 1.81223957e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="pastella",type="local"} 1.73844475e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="phorge",type="local"} 3.1308072e+08
gickup_repo_time{hoster="github.com",owner="cooperspencer",repository="purpur-docker",type="local"} 1.68487166e+08

PS: I hope you are well and get well soon.

@cooperspencer
Copy link
Owner

if you want to try it out, just checkout prometheus_improvement and build it.

@michaelrommel
Copy link

michaelrommel commented Feb 8, 2023

Hi Andreas,

I gave the building a try, but now I am kind of stuck… pickup is running on a linux server in my home network in the docker container. I did not want to pollute the server with additional development tools and therefore attempted to build it on my Mac.

I installed Docker Desktop and got so far, that I can build the container. But now the container images is basically local to that Docker Desktop instance. Any idea, how I could get the Linux Server to pull the image from the Mac? Unusual question, I know, but maybe you know the answer off the top of your head. I will be researching on my own as well, how to get the image over…

Will keep you posted..

Michael.

Edit: docker save and docker load should do the trick, will give that a try...

@michaelrommel
Copy link

Hm, I guess, I need another linux based build machine… The image on the Mac was build for the linux/arm64 architecture, whereas the server needs a linux/amd64 build. Cross building on the Mac fails with:

 > [builder 9/9] RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o app .:                                             
#0 19.41 go build golang.org/x/crypto/chacha20: /usr/local/go/pkg/tool/linux_amd64/compile: signal: segmentation fault  

A task for another day - too late for now...

@michaelrommel
Copy link

Got it running. Now I am struggling with a multi source configuration:

  • backup two repos from GitHub
  • and one from a gitea Instance
  • to the same local directory
  • but in different intervals.

Is there an example config available? I noticed the comment at the end of the example config that one should be able to specify "pairs", but no matter which YAML config I try, gickup will fail with a parsing error…

@michaelrommel
Copy link

So, most of it works now, I have configured it for now with the same 6h interval. But ideally I would like to increase the interval for the GitHub hosted repos to 2 days or even weekly to be a good citizen… If you can provide guidance for the yml file, that would be great.

Here is how I configured the Grafana instance:

I used in one graph the gickup_repos_discovered metric with a Sum() Operation.

image

In the next one I have the same metric and another one, another Sum() of gickup_repo_success, both of those metrics are not shown (the eye is crossed out)
Then I have a third "Expression" that divides the above and then displays a percentage as Gauge.
Let's see how that evolves over time…

image

The copies seem to work fine:

root@seagull:/var/lib/docker/volumes/gitea_gickup/_data# find . -maxdepth 4
.
./github.com
./github.com/michaelrommel
./github.com/michaelrommel/blog.git
./github.com/michaelrommel/blog.git/1675896901
./github.com/michaelrommel/blog.git/1675897201
./github.com/michaelrommel/blog.git/1675896601
./github.com/michaelrommel/rsyncmachine.git
./github.com/michaelrommel/rsyncmachine.git/1675897205
./github.com/michaelrommel/rsyncmachine.git/1675896902
./github.com/michaelrommel/rsyncmachine.git/1675896604
./seagull.layer-7.net:4000
./seagull.layer-7.net:4000/rommel
./seagull.layer-7.net:4000/rommel/squeezelite.git
./seagull.layer-7.net:4000/rommel/squeezelite.git/1675897206
./seagull.layer-7.net:4000/rommel/squeezelite.git/1675896903
./seagull.layer-7.net:4000/rommel/squeezelite.git/1675894800
./seagull.layer-7.net:4000/rommel/squeezelite.git/1675894500
./seagull.layer-7.net:4000/rommel/squeezelite.git/1675896605

If that runs smoothly, then all my wishes are already fulfilled - thanks a lot for the quick amendment!!

Michael.

@cooperspencer
Copy link
Owner

yesterday I've built buddyspencer/gickup:dev for you, but fell asleep during the build.

Running gickup with different intervals is pretty simple, either create multiple config files and use both at startup, or put everything in the same file like this:

source:
  github:
    - user: cooperspencer

destination:
  local:
    - path: ~/backup
      structured: true

cron: "0 * * * *"

---

source:
  github:
    - user: michaelrommel

destination:
  local:
    - path: ~/backup
      structured: true

cron: "5 * * * *"

@michaelrommel
Copy link

Seems I almost had it: I had one more line with three dashes at the beginning of the file… Will try that later, thanks!!

@cooperspencer
Copy link
Owner

I just pushed the latest changes to buddyspencer/gickup:dev, if you want to try it.

@michaelrommel
Copy link

It works fine for me! I noticed that there is now a conditional testing for the token, I guess that was the reason why - when I first started out with the gitea conf without a token and only username/password pair - it didn't work for me until I added the token :-)

I have changed the Grafana panel to the Bar Gauge style and with a bit of tinkering I now get this display, which is ideal for my dashboard:

image

It's perfect now for me. Now on to adding the rest of the repos on Github and changing the intervals (I have them running now separately). Perhaps one note would be good that also the prometheus config needs to be in the first definition of "pairs".

Thanks Andreas and have a nice evening!

@cooperspencer
Copy link
Owner

I am glad it works out for you. The changes will be in the newest release.

@DavidGL17
Copy link

Hi, thank you very much for the updates to the prometheus metrics available. I would be very interested in replicating the dashboard you created @michaelrommel, are you ok with sharing it ?^^

@michaelrommel
Copy link

Dear @DavidGL17,

I apologize for the late reply and wish you a good start into 2024. I wanted to give you as much usable information as possible and therefore extracted the gickup portion out of my main dashboard. You should be able to import that directly into Grafana and then you have to change obviously the names of your hosters according to the gickup config file.

gickup-demo-dashboard.json

I hope you will find this useful.

Cheers, Michael.

@DavidGL17
Copy link

Hey @michaelrommel

No worries, have a happy 2024 too. I managed to import it into my Graphana dashboard and it works perfectly, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants