cmd

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "overseerr-exporter",
	Short: "Export request metrics from Overseerr",
	Long:  `Export request metrics from an Overseerr instance to a prometheus database`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		setupLogger()
		logrus.WithFields(logrus.Fields{
			"command": cmd.Name(),
			"args":    args,
		}).Debugln("running command")
	},
	PreRun: func(cmd *cobra.Command, args []string) {
		setOverseer()
	},
	Run: func(cmd *cobra.Command, args []string) {
		prometheus.MustRegister(prometheus.NewBuildInfoCollector())
		prometheus.MustRegister(collector.NewRequestCollector(overseerr, scrapeGenres, scrapeCompanies))
		prometheus.MustRegister(collector.NewUserCollector(overseerr))

		handler := promhttp.Handler()
		http.Handle(metricsPath, handler)
		http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
			w.Write([]byte(`<html>
		<head><title>Overseerr Exporter</title></head>
		<body>
		<h1>Overseerr Exporter</h1>
		<p><a href="` + metricsPath + `">Metrics</a></p>
		</body>
		</html>`))
		})

		if err := http.ListenAndServe(listenAddress, nil); err != nil {
			logrus.WithField("err msg", err.Error()).Fatalln("🆘	http server failed: exiting")
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL