flo-at / minmon

MinMon - an opinionated minimal monitoring and alarming tool
Apache License 2.0
357 stars 13 forks source link

Support config directories #26

Open flo-at opened 1 year ago

flo-at commented 1 year ago

It would be good to have the option to use a config directory as an alternative to the single config file. See #20

antedebaas commented 2 months ago

I would love this. It would allow me to place config files per service in their own ansible roles I use for deployment.

flo-at commented 2 months ago

@antedebaas Can you give an example on how you would like to split the config into multiple files? It doesn't need to have correct syntax or anything but just show which parts would go into which files.

There are two implenentations I'm thinking about for this feature.

  1. Basically just concatenate the files in memory and proceed with that file. This is very simple to implement but the downside is that line numbers in error messages will be meaningless (for all but the first file).
  2. Parse each file individually and merge the config. Also quite simple to implement and has better error output. The problem here is that cross-references (across multiple files) between checks and actions are required. I think 2 is the nicer approach because of the error messages. 1 would be super easy to implement but that's the only advantage I can right now.

This is 1 of 2 tickets left in the v1.0 release plan so I'd really like to see this done.

antedebaas commented 2 months ago

i think the 2nd makes more sense. i had a httpd style in mind where the main file can tell to include other files in the httpd case i've included /etc/httpd/conf.virtual.d/* i can then put all config files in that dir and reload the config to apply it.

flo-at commented 1 month ago

The httpd include-style does not work well for TOML files but there's still the option to specify a directory instead of a single TOML file and loading all files from that directory. That's probably the way to go here. I also prefer option 2 from above. It's on my todo list and there should be some free time in october to get this done.

flo-at commented 1 week ago

The way serde works makes it a bit difficult to parse multiple files at the same time. Parsing them one after another requires some parts of the validation that serde currently handles to be reimplemented in MinMon which I would like to avoid. It seems the best solution (in terms of avoiding code duplication and simple implementation) would be to parse the concatenation of all config files and mention the line offsets of a file when an error occurs. Adjusting the line numbers in the error message isn't an option unfortunately.

I'll finish the implementation soon, there's not much left to be done.