Serilog.Sinks.InfluxDB.Syslog
2.3.0
See the version list below for details.
dotnet add package Serilog.Sinks.InfluxDB.Syslog --version 2.3.0
NuGet\Install-Package Serilog.Sinks.InfluxDB.Syslog -Version 2.3.0
<PackageReference Include="Serilog.Sinks.InfluxDB.Syslog" Version="2.3.0" />
paket add Serilog.Sinks.InfluxDB.Syslog --version 2.3.0
#r "nuget: Serilog.Sinks.InfluxDB.Syslog, 2.3.0"
// Install Serilog.Sinks.InfluxDB.Syslog as a Cake Addin #addin nuget:?package=Serilog.Sinks.InfluxDB.Syslog&version=2.3.0 // Install Serilog.Sinks.InfluxDB.Syslog as a Cake Tool #tool nuget:?package=Serilog.Sinks.InfluxDB.Syslog&version=2.3.0
Serilog.Sinks.InfluxDB.Syslog
A serilog sink that writes events to InfluxDB in syslog message format as described on the Influx blog.
Supports platforms compatible with the .NET Platform Standard netstandard2.0
.
Compatible with InfluxDB v2.0
Warning: Use library versions prior 2.0 for compatibility with influxdb v1.X
Getting Started
Version 2 (InfluxDB v2.X)
To get started install the Serilog.Sinks.InfluxDB.Syslog package:
PM> Install-Package Serilog.Sinks.InfluxDB.Syslog
OR
$ dotnet add package Serilog.Sinks.InfluxDB.Syslog
If running locally for development purpose, you can use docker-compose-v2.yml at root of this repository and adapt volumes if needed
$ docker-compose -f docker-compose-v2.yml up -d
Point the logger to InfluxDb (quickest way using default _internal database):
Log.Logger = new LoggerConfiguration()
.WriteTo.InfluxDB(applicationName: "Quick test",
uri: new Uri("http://127.0.0.1:8086"),
organizationId: "88e1f5a5ad074d9e", // Organization Id - unique id can be found under Profile > About > Common Ids)
bucketName: "logs",
token: "bGfBKhSycNiUOia4k7peib2jHFewkz3o6Hv2uz1xAoUcdnEFRW7cHn03KICySLemA4VPZKvc0CwzSQT8GNl2DA==")
.CreateLogger();
Another sample using InfluxDBSinkOptions for more control over periodic batching options and connection information:
Log.Logger = new LoggerConfiguration()
.WriteTo.InfluxDB(new InfluxDBSinkOptions()
{
ApplicationName = "fluentSample",
InstanceName = "fluentSampleInstance",
ConnectionInfo = new InfluxDBConnectionInfo()
{
Uri = new Uri("http://127.0.0.1:8086"),
BucketName = "logs",
OrganizationId = "88e1f5a5ad074d9e", // Organization Id - unique id can be found under Profile > About > Common Ids
// To be set if bucket already created and give write permission and set CreateBucketIfNotExists to false
Token = null,
CreateBucketIfNotExists = true,
//To specify if Bucket needs to be created and if token not known or without all access permissions
AllAccessToken = "bGfBKhSycNiUOia4k7peib2jHFewkz3o6Hv2uz1xAoUcdnEFRW7cHn03KICySLemA4VPZKvc0CwzSQT8GNl2DA==",
BucketRetentionPeriod = TimeSpan.FromDays(1)
},
BatchOptions = new PeriodicBatching.PeriodicBatchingSinkOptions()
{
BatchSizeLimit = 50,
Period = TimeSpan.FromSeconds(10),
EagerlyEmitFirstEvent = true,
QueueLimit = null
}
})
.CreateLogger();
If using appsettings.json
for configuration the following example illustrates using InfluxDb and Console sinks.
{
"Serilog": {
"Using": ["Serilog.Sinks.Console", "Serilog.Sinks.InfluxDB.Syslog"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo:Influx": {
"Name": "InfluxDB",
"Args": {
"sinkOptions": {
"ApplicationName": "testApp",
"InstanceName": "testInstance",
"ConnectionInfo": {
"Uri": "http://localhost:8086",
"BucketName": "logs",
"OrganizationId": "88e1f5a5ad074d9e",
"Token": "edBlcWgLkoPOituD_6V1ftCznpDR8niFcF46MJCSYuSxc1FM_srm9cuoc84yX5kOjOH_11Zvxk_juqr44S-57A==",
"CreateBucketIfNotExists": false
//"Username": "influxdbroot",
//"Password": "TBD"
"BucketRetentionPeriod": "7.00:00:00",
},
"BatchOptions": {
"EagerlyEmitFirstEvent": true,
"BatchSizeLimit": 100,
"Period": "0.00:00:30",
"QueueLimit": 1000000
}
}
}
},
"Properties": {
"Application": "Serilog Sink InfluxDb Console Sample"
}
}
}
All those samples can be found under project subdirectory samples of this repository.
Version 1 (InfluxDB v1.X)
To get started install the Serilog.Sinks.InfluxDB.Syslog package:
PM> Install-Package Serilog.Sinks.InfluxDB.Syslog -Version 1.3.1
OR
$ dotnet add package Serilog.Sinks.InfluxDB.Syslog --version 1.3.1
If running locally for development purpose, you can use docker-compose.yml at root of this repository and adapt volumes if needed
$ docker-compose -f docker-compose.yml up -d
Point the logger to InfluxDb (quickest way using default _internal database):
Log.Logger = new LoggerConfiguration()
.WriteTo.InfluxDB(
applicationName: "Quick Test",
uri : new Uri("http://127.0.0.1:8086"));
Another sample using InfluxDBSinkOptions for more control over periodic batching options and connection information:
Log.Logger = new LoggerConfiguration()
.WriteTo.InfluxDB(new InfluxDBSinkOptions()
{
ApplicationName = "fluentSample", // Application Name
InstanceName = "fluentSampleInstance", // Instance or Environment Name
ConnectionInfo = new InfluxDBConnectionInfo() // Connection Details
{
Uri = new Uri("http://127.0.0.1:8086"),
DbName = "_internal",
},
BatchOptions = new PeriodicBatching.PeriodicBatchingSinkOptions()
{
BatchSizeLimit = 50,
Period = TimeSpan.FromSeconds(10),
EagerlyEmitFirstEvent = true,
QueueLimit = null
}
})
.CreateLogger();
If using appsettings.json
for configuration the following example illustrates using InfluxDb and Console sinks.
{
"Serilog": {
"Using": ["Serilog.Sinks.Console", "Serilog.Sinks.InfluxDB.Syslog"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "InfluxDB",
"Args": {
"sinkOptions": {
"applicationName": "testApp",
"instanceName": "testInstance",
"ConnectionInfo": {
"Uri": "http://localhost:8086",
"DbName": "_internal",
"Username": "",
"Password": ""
},
"BatchOptions": {
"EagerlyEmitFirstEvent": true,
"BatchSizeLimit": 200,
"Period": "0.00:00:30",
"QueueLimit": null
}
}
}
}
],
"Properties": {
"Application": "Serilog Sink InfluxDb Console Sample"
}
}
}
Build Status
Branch | Status |
---|---|
Main Branch |
Benchmarks
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
Intel Core i7-2640M CPU 2.80GHz (Sandy Bridge), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=5.0.101
[Host] : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203), X64 RyuJIT [AttachedDebugger]
DefaultJob : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203), X64 RyuJIT
Method | N | Mean | Error | StdDev |
---|---|---|---|---|
LogSomething | 1000 | 5.781 us | 0.1832 us | 0.5315 us |
Troubleshooting
Nothing showed up, what can I do?
If events don't appear in InfluxDb after looking in corresponding database via Chronograf, Grafana or else. Either your application was unable to contact the InfluxDb server, or else the InfluxDb server rejected the log events for some reason.
Server-side issues
The InfluxDb server may reject incoming events if they're missing required credentials (check troubleshoot articles on influxdb, if the payload is corrupted somehow, or if the log events are too large to accept.
Client-side issues
If there's no information in the ingestion log, the application was probably unable to reach the server because of network configuration or connectivity issues. These are reported to the application through Serilog's SelfLog
.
Add the following line after the logger is configured to print any error information to the console:
Serilog.Debugging.SelfLog.Enable(Console.Error);
If the console is not available, you can pass a delegate into SelfLog.Enable()
that will be called with each error message:
Serilog.Debugging.SelfLog.Enable(message => {
// Do something with `message`
});
Troubleshooting checklist
- Check InfluxDb connectivity and if Server-side issues see section above
- Turn on the Serilog SelfLog as described above to check for connectivity problems and other issues on the client side.
- Make sure your application calls Log.CloseAndFlush(), or disposes the root Logger, before it exits - otherwise, buffered events may be lost.
- If your app is a Windows console application, it is also important to close the console window by exiting the app; Windows console apps are terminated "hard" if the close button in the title bar is used, so events buffered for sending to InfluxDb may be lost if you use it.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- InfluxDB.Client (>= 4.9.0)
- Serilog (>= 2.12.0)
- Serilog.Sinks.PeriodicBatching (>= 3.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.3.5 | 16,104 | 10/27/2023 |
2.3.4 | 2,997 | 7/18/2023 |
2.3.3 | 2,037 | 1/30/2023 |
2.3.2 | 947 | 1/11/2023 |
2.3.1 | 341 | 1/11/2023 |
2.3.0 | 381 | 1/8/2023 |
2.2.0 | 1,771 | 8/20/2022 |
2.1.2 | 411 | 8/13/2022 |
2.1.1 | 5,395 | 3/8/2022 |
2.1.0 | 12,415 | 12/12/2021 |
2.0.3 | 356 | 12/5/2021 |
2.0.2 | 2,216 | 6/19/2021 |
2.0.1 | 856 | 3/13/2021 |
2.0.0 | 877 | 2/13/2021 |
1.4.1 | 616 | 3/8/2022 |
1.4.0 | 1,124 | 12/12/2021 |
1.3.2 | 2,301 | 3/13/2021 |
1.3.1 | 2,959 | 1/23/2021 |
1.3.0 | 446 | 1/21/2021 |
1.2.0 | 619 | 9/17/2020 |
1.1.0 | 557 | 8/14/2020 |
1.0.0 | 571 | 8/14/2020 |
2.3.0:
- Extended Fields/Tags to support name mapping https://github.com/pada57/serilog-sinks-influxdb/issues/20
- Fix field type ProcId to be string instead of integer as in syslog format https://github.com/pada57/serilog-sinks-influxdb/issues/21
- Fix issue with extended tags which were adding quotes for string https://github.com/pada57/serilog-sinks-influxdb/issues/18
- Make optional application name and instance name https://github.com/pada57/serilog-sinks-influxdb/issues/23
- Update nuget dependencies including InfluxDB.Client and Serilog.Sinks.PeriodicBatching
2.2.0:
- Add support for Extended fields and Extended tags
2.1.2:
- Update nuget dependencies including InfluxDB.Client and Serilog
2.1.1:
- Update nuget dependencies including InfluxDB.Client and Serilog.Sinks.PeriodicBatching
2.1.0 (only for InfluxDB v2.XX):
- New parameter IncludeFullException default to false
- Update nuget dependencies
2.0.3:
- Update nuget dependencies including InfluxDB.Client
2.0.2:
- Update nuget dependencies including InfluxDB.Client
2.0.1:
- Update nuget dependencies including InfluxDB.Client
2.0: Support for InfluxDB v2, not compatible with v1
- Change main dependency from InfluxData.Net to InfluxDB.Client
- Add two authentication mode with Token or Credentials (User/Password)
- Add new BatchOptions to have control over batch size / queue limit / period / eager first event emition
1.4.0 (only for InfluxDB v1.XX):
- New parameter IncludeFullException default to false
- Update nuget dependencies
1.3.2:
- Update nuget dependencies
1.3.1:
- Adapting namespaces
1.3:
- Handling of response with selflog and throwing exceptions letting PeriodicBatchingSink handling backoffs/retries
- Adding single InfluxDBSinkOptions for creating sink, kept backward compatibility for previous extension methods -
- Add Benchmark tests and unit tests
- Add sample projects
- Add documentation and license (MIT)
- Removed unused method
1.2:
- Add instance name and rename source to application name
- Remove tag on message template
- Map facility to instance name
- Remove filtering of logevents and directly escape message after formatting
- Update to Serilog 2.10 and Serilog.Sinks.PeriodicBatching 2.3
1.1:
- Use Uri instead of address/port in extensions methods and also in InfluxDbCOnnectionInfo object
1.0:
- Forked fromhttps://github.com/ThiagoBarradas/serilog-sinks-influxdb
- Adaption for syslog format
- Fix 400 errors due to invalid characters with JSON payload