Skip to content

Commit 41d37aa

Browse files
committed
[feat] [pkg/stanza]: add includeProviders to windows input
Signed-off-by: Szilard Parrag <[email protected]>
1 parent 93f9355 commit 41d37aa

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

.chloggen/add-include-providers.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: eventlogreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: add include_providers parameter to eventlogreceiver
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [38517]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user, api]

pkg/stanza/operator/input/windows/config_all.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Config struct {
3636
Raw bool `mapstructure:"raw,omitempty"`
3737
SuppressRenderingInfo bool `mapstructure:"suppress_rendering_info,omitempty"`
3838
ExcludeProviders []string `mapstructure:"exclude_providers,omitempty"`
39+
IncludeProviders []string `mapstructure:"include_providers,omitempty"`
3940
Remote RemoteConfig `mapstructure:"remote,omitempty"`
4041
}
4142

pkg/stanza/operator/input/windows/config_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (c *Config) Build(set component.TelemetrySettings) (operator.Operator, erro
5050
pollInterval: c.PollInterval,
5151
raw: c.Raw,
5252
excludeProviders: createProvidersSet(c.ExcludeProviders),
53+
includeProviders: createProvidersSet(c.IncludeProviders),
5354
remote: c.Remote,
5455
}
5556
input.startRemoteSession = input.defaultStartRemoteSession

pkg/stanza/operator/input/windows/input.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Input struct {
3030
startAt string
3131
raw bool
3232
excludeProviders map[string]struct{}
33+
includeProviders map[string]struct{}
3334
pollInterval time.Duration
3435
persister operator.Persister
3536
publisherCache publisherCache
@@ -241,6 +242,14 @@ func (i *Input) getPublisherName(event Event) (name string, excluded bool) {
241242
i.Logger().Error("Failed to get provider name", zap.Error(err))
242243
return "", true
243244
}
245+
246+
// Check first for includeProviders
247+
if len(i.includeProviders) != 0 {
248+
if _, include := i.includeProviders[providerName]; !include {
249+
return "", true
250+
}
251+
}
252+
244253
if _, exclude := i.excludeProviders[providerName]; exclude {
245254
return "", true
246255
}
@@ -269,7 +278,7 @@ func (i *Input) renderDeepAndSend(ctx context.Context, event Event, publisher Pu
269278

270279
// processEvent will process and send an event retrieved from windows event log.
271280
func (i *Input) processEventWithoutRenderingInfo(ctx context.Context, event Event) error {
272-
if len(i.excludeProviders) == 0 {
281+
if len(i.excludeProviders) == 0 && len(i.includeProviders) == 0 {
273282
return i.renderSimpleAndSend(ctx, event)
274283
}
275284
if _, exclude := i.getPublisherName(event); exclude {

receiver/windowseventlogreceiver/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Tails and parses logs from windows event log API using the [opentelemetry-log-co
2929
| `raw` | false | If false, the body of emitted log records will contain a structured representation of the event. Otherwise, the body will be the original XML string. |
3030
| `suppress_rendering_info` | false | If false, [additional syscalls](https://learn.microsoft.com/en-us/windows/win32/api/winevt/nf-winevt-evtformatmessage#remarks) may be made to retrieve detailed information about the event. Otherwise, some unresolved values may be present in the event. |
3131
| `exclude_providers` | [] | One or more event log providers to exclude from processing. |
32+
| `include_providers` | [] | One or more event log providers to include into processing. |
3233
| `storage` | none | The ID of a storage extension to be used to store bookmarks. Bookmarks allow the receiver to pick up where it left off in the case of a collector restart. If no storage extension is used, the receiver will manage bookmarks in memory only. |
3334
| `retry_on_failure.enabled` | `false` | If `true`, the receiver will pause reading a file and attempt to resend the current batch of logs if it encounters an error from downstream components. |
3435
| `retry_on_failure.initial_interval` | `1 second` | Time to wait after the first failure before retrying. |

0 commit comments

Comments
 (0)