mongodb_exporter icon indicating copy to clipboard operation
mongodb_exporter copied to clipboard

Add logRotate to mongodb_exporter

Open zhihuiFan opened this issue 7 years ago • 7 comments

Hi @dcu Currently I'm using mongodb_expoerter in my environment, and I don't want to install too many agents. Now I want a feature to a different url path.

  1. allow a user to logRotate regularly. Like once per day
  2. configure a log retention policy so that the old log can be purged automatically.

I know it is not part of Prometheus agent, so I want to know if it is welcome to send such PR to this repo. Personally, I do want add it.

Thanks

zhihuiFan avatar Feb 25 '18 14:02 zhihuiFan

Prometheus exporters do not generate logs normally, what log do you want to configure & rotate?

avishefi avatar Feb 25 '18 14:02 avishefi

The logs of mongodb, sometime it may take a lot of spaces

zhihuiFan avatar Feb 25 '18 14:02 zhihuiFan

Prometheus exporters expose metrics, they do not manage log files

avishefi avatar Feb 26 '18 08:02 avishefi

OP probably refers to all the stuff accumulating at /var/log/prometheus in the form prometheus-mongodb-exporter.MACHINE.TIMESTAMP. Those log files are generated by prometheus-mongodb-exporter and by default they take a lot of disk space.

I agree that it would be nice to have a procedure allowing the user to rotate those logs.

sanvila avatar Apr 23 '18 07:04 sanvila

my log file is named like mongodb_exporter.ip-10-72-229-205.ec2-user.log.INFO.20180502-212317.24179.

How to change the log level to others than INFO?

gao-jian-zz avatar May 02 '18 21:05 gao-jian-zz

OP probably refers to all the stuff accumulating at /var/log/prometheus in the form prometheus-mongodb-exporter.MACHINE.TIMESTAMP. Those log files are generated by prometheus-mongodb-exporter and by default they take a lot of disk space.

I agree that it would be nice to have a procedure allowing the user to rotate those logs.

Yeah, I'd like to know what and how generates those files. The largest one I have is aroung 350 MB and others are no less than 80 MB. Would be cool if there is some way to rotate/compress/purge old those file.

zjagust avatar Sep 26 '18 13:09 zjagust

You can configure glog to log to stderr -logtostderr=true or log to another dir -log_dir="<ANOTHER_DIR>" to avoid filling up disk space. I need to redirect logs for long running containers.

More documentation for glog: https://godoc.org/github.com/golang/glog

IntiGabriel avatar Nov 04 '19 15:11 IntiGabriel