chop-dbhi / prometheus-sql

Service that exposes Prometheus metrics for a SQL result set.
BSD 2-Clause "Simplified" License
202 stars 55 forks source link

signal to reload changes within queryDir #23

Open andybrown668 opened 7 years ago

andybrown668 commented 7 years ago

Thank you for this work!

I use this in a production environment and deploy changes to contents of a queries folder with ansible. But I currently need to restart the prometheus-sql container to make it notice the changed queries.

It'd be great if prometheus-sql could respond to a signal (SIGINT?) and reload the queries.

cheers Andy

bruth commented 7 years ago

Good suggestion. I have actually run into this myself. This is a good idea. Another option is to add a -watch flag to automatically reload on detected changes (fsnotify or something similar could be used).

andybrown668 commented 7 years ago

Would the fsnotify idea force users into atomically copying the changed configs? (like a copy-to-temp then rename to .yml). I like the idea anyway, and requiring the -watch flag makes it a nice opt-in. So there's no duplication of effort, would you like me to take a look at coming up with a PR? (work's always busy but we've had a huge speed-up from all the open source software out here)

bruth commented 7 years ago

@andybrown668 Yes good point. I suppose if only the config files are being watched then any queries in a directory or file could be updated prior to "touching" the config files to trigger the change. Or the primary config could be the only thing that triggers the reload.

That being said, the SIGHUP solution is simpler and likely preferred because of this case. That would be great if you could investigate this!

andybrown668 commented 7 years ago

cool - please give me a week to come up with something; could be sooner, but I don't want to overpromise or block someone else contributing if I'm too slow getting it done

mscifo commented 7 years ago

I just whipped this up to handle this issue https://github.com/mscifo/prometheus-sql-config

bruth commented 7 years ago

@mscifo Nice solution!

simonpie commented 6 years ago

Another solution that would be useful would be to have a rest end point to force reload like prometheus. Then, one can use a side container in kubernetes to reload the main one on config map change : https://github.com/jimmidyson/configmap-reload