static void Main(string[] args) { // Initialize the global logging, usually this should go to the regular Windows eventlog GVars.MyLog = new System.Diagnostics.EventLog("Application"); GVars.MyLog.Source = "PrometheusNodeExporter"; // Load all plugins an initialize the metrics NodeCollector.Core.PluginCollection availablePlugins = NodeCollector.Core.PluginSystem.LoadCollectors(); foreach (NodeCollector.Core.INodeCollector collector in availablePlugins) { collector.RegisterMetrics(); } string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); ushort port = NodeExporterWindows.Properties.Settings.Default.Port; string metricUrl = "metrics/"; GVars.MyLog.WriteEntry(string.Format("Start Prometheus exporter v{0} service on port :{1}/tcp (url {2}).", version, port, metricUrl), EventLogEntryType.Information, 0); MetricServer metricServer = new MetricServer(port: port, url: metricUrl); metricServer.Start(); Console.WriteLine("Press [ENTER] twice to exit..."); Console.ReadLine(); Console.ReadLine(); }
protected override void OnStart(string[] args) { // Initialize the global logging, usually this should go to the regular Windows eventlog GVars.MyLog = this.eventLogMaster; // Load all plugins an initialize the metrics NodeCollector.Core.PluginCollection availablePlugins = NodeCollector.Core.PluginSystem.LoadCollectors(); foreach (NodeCollector.Core.INodeCollector collector in availablePlugins) { collector.RegisterMetrics(); } string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); ushort port = NodeExporterWindows.Service.Properties.Settings.Default.Port; string metricUrl = "metrics/"; GVars.MyLog.WriteEntry(string.Format("Start Prometheus exporter v{0} service on port :{1}/tcp (url {2}).", version, port, metricUrl), EventLogEntryType.Information, 0); MetricServer metricServer = new MetricServer(port: port, url: metricUrl); metricServer.Start(); }