vector/internal_events/
windows.rs

1use metrics::counter;
2use vector_lib::internal_event::InternalEvent;
3use vector_lib::internal_event::{error_stage, error_type};
4
5#[derive(Debug)]
6pub struct WindowsServiceStart<'a> {
7    pub already_started: bool,
8    pub name: &'a str,
9}
10
11impl InternalEvent for WindowsServiceStart<'_> {
12    fn emit(self) {
13        info!(
14            already_started = %self.already_started,
15            name = self.name,
16            "Started Windows Service.",
17        );
18        counter!(
19            "windows_service_start_total",
20            "already_started" => self.already_started.to_string(),
21        )
22        .increment(1);
23    }
24}
25
26#[derive(Debug)]
27pub struct WindowsServiceStop<'a> {
28    pub already_stopped: bool,
29    pub name: &'a str,
30}
31
32impl InternalEvent for WindowsServiceStop<'_> {
33    fn emit(self) {
34        info!(
35            already_stopped = %self.already_stopped,
36            name = ?self.name,
37            "Stopped Windows Service.",
38        );
39        counter!(
40            "windows_service_stop_total",
41            "already_stopped" => self.already_stopped.to_string(),
42        )
43        .increment(1);
44    }
45}
46
47#[derive(Debug)]
48pub struct WindowsServiceRestart<'a> {
49    pub name: &'a str,
50}
51
52impl InternalEvent for WindowsServiceRestart<'_> {
53    fn emit(self) {
54        info!(
55            name = ?self.name,
56            "Restarted Windows Service."
57        );
58        counter!("windows_service_restart_total").increment(1)
59    }
60}
61
62#[derive(Debug)]
63pub struct WindowsServiceInstall<'a> {
64    pub name: &'a str,
65}
66
67impl InternalEvent for WindowsServiceInstall<'_> {
68    fn emit(self) {
69        info!(
70            name = ?self.name,
71            "Installed Windows Service.",
72        );
73        counter!("windows_service_install_total").increment(1);
74    }
75}
76
77#[derive(Debug)]
78pub struct WindowsServiceUninstall<'a> {
79    pub name: &'a str,
80}
81
82impl InternalEvent for WindowsServiceUninstall<'_> {
83    fn emit(self) {
84        info!(
85            name = ?self.name,
86            "Uninstalled Windows Service.",
87        );
88        counter!("windows_service_uninstall_total").increment(1);
89    }
90}
91
92#[derive(Debug)]
93pub struct WindowsServiceDoesNotExistError<'a> {
94    pub name: &'a str,
95}
96
97impl InternalEvent for WindowsServiceDoesNotExistError<'_> {
98    fn emit(self) {
99        error!(
100            message = "Windows service does not exist. Maybe it needs to be installed.",
101            name = self.name,
102            error_code = "service_missing",
103            error_type = error_type::CONDITION_FAILED,
104            stage = error_stage::PROCESSING,
105            internal_log_rate_limit = true,
106        );
107        counter!(
108            "component_errors_total",
109            "error_code" => "service_missing",
110            "error_type" => error_type::CONDITION_FAILED,
111            "stage" => error_stage::PROCESSING,
112        )
113        .increment(1);
114    }
115}