Serilog.Enrichers.Kubernetes
1.0.2
See the version list below for details.
dotnet add package Serilog.Enrichers.Kubernetes --version 1.0.2
NuGet\Install-Package Serilog.Enrichers.Kubernetes -Version 1.0.2
<PackageReference Include="Serilog.Enrichers.Kubernetes" Version="1.0.2" />
paket add Serilog.Enrichers.Kubernetes --version 1.0.2
#r "nuget: Serilog.Enrichers.Kubernetes, 1.0.2"
// Install Serilog.Enrichers.Kubernetes as a Cake Addin #addin nuget:?package=Serilog.Enrichers.Kubernetes&version=1.0.2 // Install Serilog.Enrichers.Kubernetes as a Cake Tool #tool nuget:?package=Serilog.Enrichers.Kubernetes&version=1.0.2
Serilog.Enrichers.Kubernetes
The Kubernetes enricher for Serilog. This enricher makes use of the Downward Api. Please make sure this is setup before trying to Enrich using this package!
- Expose Pod Information to Containers Through Files
- Expose Pod Information to Containers Through Environment Variables
Installation
To use the enricher, first install the NuGet package:
Install-Package Serilog.Enrichers.Kubernetes
dotnet add package Serilog.Enrichers.Kubernetes
Usage
Then add one of the following to the LoggerConfiguration()
:
Enrich.WithK8sPodNamespace()
Enrich.WithK8sPodName()
Enrich.WithK8sPodUID()
Enrich.WithK8sPodAnnotations()
Enrich.WithK8sPodLabels()
By default the Enrichers will be in DownwardApiMethod.File
mode of the DownwardApi Documentation File Method. You can look which of the properties have a default set, you can also overide it.
You can also choose to use the Environment Variable way by using DownwardApiMethod.EnvironmentVariable
Documentation ENV. You can look which of the properties have a default set, you can also overide it.
Downward api File mode
See examples/full-example-downwardapi-file-mode.yaml
Code usage | Default path | Kubernetes Configuration variable |
---|---|---|
Enrich.WithK8sPodNamespace() |
/etc/podinfo/namespace |
fieldRef.fieldPath: metadata.namespace |
Enrich.WithK8sPodName() |
/etc/podinfo/name |
fieldRef.fieldPath: metadata.name |
Enrich.WithK8sPodUID() |
/etc/podinfo/uid |
fieldRef.fieldPath: metadata.uid |
Enrich.K8sPodNodeName() |
/etc/podinfo/node_name |
fieldRef.fieldPath: spec.nodeName |
Enrich.K8sPodHostIP() |
/etc/podinfo/host_ip |
fieldRef.fieldPath: status.hostIP |
Enrich.K8sPodIP() |
/etc/podinfo/ip |
fieldRef.fieldPath: status.podIP |
Enrich.K8sPodServiceAccountName() |
/etc/podinfo/service_account_name |
fieldRef.fieldPath: spec.serviceAccountName |
Enrich.K8sPodCPULimit() |
/etc/podinfo/cpu_limit |
resourceFieldRef.resource: limits.cpu |
Enrich.K8sPodCPURequest() |
/etc/podinfo/cpu_request |
resourceFieldRef.resource: requests.cpu |
Enrich.K8sPodMemoryLimit() |
/etc/podinfo/mem_limit |
resourceFieldRef.resource: limits.memory |
Enrich.K8sPodMemoryRequest() |
/etc/podinfo/mem_request |
resourceFieldRef.resource: requests.memory |
Enrich.K8sPodEphemeralStorageLimit() |
/etc/podinfo/ephemeral_storage_limit |
resourceFieldRef.resource: limits.ephemeral-storage |
Enrich.K8sPodEphemeralStorageRequest() |
/etc/podinfo/ephemeral_storage_request |
resourceFieldRef.resource: requests.ephemeral-storage |
Enrich.KubernetesPodAnnotationsEnricher() |
/etc/podinfo/annotations |
fieldRef.fieldPath: status.annotations |
Enrich.KubernetesPodLabelsEnricher() |
/etc/podinfo/labels |
fieldRef.fieldPath: status.labels |
Downward api Environment Variable mode
See examples/full-example-downwardapi-environment-variable-mode.yaml
Code usage | Default path | Kubernetes Configuration variable |
---|---|---|
Enrich.WithK8sPodNamespace(DownwardApiMethod.EnvironmentVariable) |
POD_NAMESPACE |
fieldRef.fieldPath: metadata.namespace |
Enrich.WithK8sPodName(DownwardApiMethod.EnvironmentVariable) |
/POD_NAME |
fieldRef.fieldPath: metadata.name |
Enrich.WithK8sPodUID(DownwardApiMethod.EnvironmentVariable) |
POD_UID |
fieldRef.fieldPath: metadata.uid |
Enrich.K8sPodNodeName(DownwardApiMethod.EnvironmentVariable) |
POD_NODE_NAME |
fieldRef.fieldPath: spec.nodeName |
Enrich.K8sPodHostIP(DownwardApiMethod.EnvironmentVariable) |
POD_HOST_IP |
fieldRef.fieldPath: status.hostIP |
Enrich.K8sPodIP(DownwardApiMethod.EnvironmentVariable) |
POD_IP |
fieldRef.fieldPath: status.podIP |
Enrich.K8sPodServiceAccountName(DownwardApiMethod.EnvironmentVariable) |
POD_SERVICE_ACCOUNT_NAME |
fieldRef.fieldPath: spec.serviceAccountName |
Enrich.K8sPodCPULimit(DownwardApiMethod.EnvironmentVariable) |
POD_CPU_LIMIT |
resourceFieldRef.resource: limits.cpu |
Enrich.K8sPodCPURequest(DownwardApiMethod.EnvironmentVariable) |
POD_CPU_REQUEST |
resourceFieldRef.resource: requests.cpu |
Enrich.K8sPodMemoryLimit(DownwardApiMethod.EnvironmentVariable) |
POD_MEMORY_LIMIT |
resourceFieldRef.resource: limits.memory |
Enrich.K8sPodMemoryRequest(DownwardApiMethod.EnvironmentVariable) |
POD_MEMORY_REQUEST |
resourceFieldRef.resource: requests.memory |
Enrich.K8sPodEphemeralStorageLimit(DownwardApiMethod.EnvironmentVariable) |
POD_EPHEMERAL_STORAGE_LIMIT |
resourceFieldRef.resource: limits.ephemeral-storage |
Enrich.K8sPodEphemeralStorageRequest(DownwardApiMethod.EnvironmentVariable) |
POD_EPHEMERAL_STORAGE_REQUEST |
resourceFieldRef.resource: requests.ephemeral-storage |
Copyright © 2021 Seppe Van Winkel - Provided under the Apache License, Version 2.0.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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. |
-
net5.0
- Serilog (>= 2.10.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.