Skip to content

Commit 4599d90

Browse files
committed
Added tagging feature
1 parent 4a51fad commit 4599d90

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

Apps/LogExporterApp/App.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ private void ConfigurePipeline()
378378
{
379379
_enrichmentDispatcher.Add(new Normalize());
380380
}
381+
if (_config!.Pipeline.TaggingProcessConfig?.Enabled is true)
382+
{
383+
_enrichmentDispatcher.Add(new Tags(_config.Pipeline.TaggingProcessConfig.Tags));
384+
}
381385
}
382386

383387
private void IncrementDropAndMaybeLog()

Apps/LogExporterApp/AppConfig.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,19 @@ public class PipelineConfig
144144
[JsonPropertyName("normalize")]
145145
public NormalizeProcess NormalizeProcessConfig { get; set; }
146146

147+
[JsonPropertyName("tagging")]
148+
public TaggingProcess TaggingProcessConfig { get; set; }
149+
147150
public class NormalizeProcess : FeatureBase
148-
{
151+
{}
149152

153+
public class TaggingProcess : FeatureBase
154+
{
155+
[Required(ErrorMessage = "tags are required when tagging is enabled.")]
156+
[JsonPropertyName("tags")]
157+
public List<string> Tags { get; set; } = new List<string>();
150158
}
159+
151160
}
152161
/// <summary>
153162
/// Shared serializer configuration for reading dnsApp.config.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Technitium DNS Server
3+
Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4+
Copyright (C) 2025 Zafer Balkan (zafer@zaferbalkan.com)
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
using System;
21+
using System.Collections.Generic;
22+
using System.Linq;
23+
24+
namespace LogExporter.Pipeline
25+
{
26+
public partial class Tags : IPipelineProcessor
27+
{
28+
private readonly string[] _tags;
29+
public Tags(IEnumerable<string> tags)
30+
{
31+
_tags = tags.ToArray();
32+
}
33+
34+
public void Process(LogEntry logEntry)
35+
{
36+
logEntry.Meta["tags"] = _tags;
37+
}
38+
39+
public void Dispose()
40+
{
41+
// If DomainCache ever needs disposal, do it here.
42+
GC.SuppressFinalize(this);
43+
}
44+
}
45+
}

Apps/LogExporterApp/dnsApp.config

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323
"enabled": false
2424
}
2525
},
26-
"pipeline":{
26+
"pipeline": {
2727
"normalize": {
2828
"enabled": true
29+
},
30+
"tagging":{
31+
"enabled": false,
32+
"tags": [ "tenant:alpha" ]
2933
}
3034
}
3135
}

0 commit comments

Comments
 (0)