Skip to content

Commit

Permalink
logs(*): remove unnecessary fluent bit filters
Browse files Browse the repository at this point in the history
Signed-off-by: Sanya Kochhar <kochhars@microsoft.com>
  • Loading branch information
SanyaKochhar authored and nojnhuh committed Mar 12, 2021
1 parent b8d533a commit cdea8fd
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 44 deletions.
1 change: 0 additions & 1 deletion charts/osm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ The following table lists the configurable parameters of the osm chart and their
| OpenServiceMesh.fluentBit.enableProxySupport | bool | `false` | Enable proxy support toggle for Fluent Bit |
| OpenServiceMesh.fluentBit.httpProxy | string | `""` | Optional HTTP proxy endpoint for Fluent Bit |
| OpenServiceMesh.fluentBit.httpsProxy | string | `""` | Optional HTTPS proxy endpoint for Fluent Bit |
| OpenServiceMesh.fluentBit.logLevel | string | `"error"` | Log level for Fluent Bit |
| OpenServiceMesh.fluentBit.name | string | `"fluentbit-logger"` | Fluent Bit sidecar container name |
| OpenServiceMesh.fluentBit.outputPlugin | string | `"stdout"` | Fluent Bit output plugin |
| OpenServiceMesh.fluentBit.primaryKey | string | `""` | Primary Key for Fluent Bit output plugin to Log Analytics |
Expand Down
20 changes: 1 addition & 19 deletions charts/osm/templates/fluentbit-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,10 @@ data:
Path /var/log/containers/osm-controller-*_{{ include "osm.namespace" . }}_osm-controller-*.log
Parser cri
Read_from_Head on
# Helps grep filter identify logs of specified level generated by clusters running on cri-o
# Adds controller pod name value to help users query logs in output
[FILTER]
Name modify
Match kube.*
Condition Key_value_matches message /"level":"{{ .Values.OpenServiceMesh.fluentBit.logLevel }}"/
Set keep true
# Helps grep filter identify logs of specified level generated by clusters running on moby, containerd
[FILTER]
Name modify
Match kube.*
Condition Key_value_matches log \\"level\\":\\"{{ .Values.OpenServiceMesh.fluentBit.logLevel }}\\"
Set keep true
# Matches logs that have met conditions in any of the above filters
[FILTER]
Name grep
Match kube.*
Regex keep true
# Removes extra "keep: true" key/value pair once matching is complete; adds controller pod name value to help users query logs in output
[FILTER]
Name modify
Match kube.*
Remove keep
Add controller_pod_name ${CONTROLLER_POD_NAME}
[OUTPUT]
Name {{ .Values.OpenServiceMesh.fluentBit.outputPlugin }}
Expand Down
14 changes: 1 addition & 13 deletions charts/osm/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@
"registry": "fluent",
"tag": "1.6.4",
"pullPolicy": "IfNotPresent",
"logLevel": "error",
"outputPlugin": "stdout",
"enableProxySupport": "false",
"httpProxy": "",
Expand All @@ -290,7 +289,6 @@
"registry",
"tag",
"pullPolicy",
"logLevel",
"outputPlugin",
"enableProxySupport",
"httpProxy",
Expand Down Expand Up @@ -334,16 +332,6 @@
"IfNotPresent"
]
},
"logLevel": {
"$id": "#/properties/OpenServiceMesh/properties/fluentBit/properties/logLevel",
"type": "string",
"title": "The logLevel schema",
"description": "The Fluent Bit log level.",
"pattern": "^(debug|info|warn|error|fatal|panic|disabled|trace)$",
"examples": [
"error"
]
},
"outputPlugin": {
"$id": "#/properties/OpenServiceMesh/properties/fluentBit/properties/outputPlugin",
"type": "string",
Expand Down Expand Up @@ -496,4 +484,4 @@
}
},
"additionalProperties": true
}
}
2 changes: 0 additions & 2 deletions charts/osm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ OpenServiceMesh:
tag: 1.6.4
# -- PullPolicy for Fluent Bit sidecar container
pullPolicy: IfNotPresent
# -- Log level for Fluent Bit
logLevel: error
# -- Fluent Bit output plugin
outputPlugin: stdout
# -- WorkspaceId for Fluent Bit output plugin to Log Analytics
Expand Down
13 changes: 6 additions & 7 deletions docs/content/docs/tasks_usage/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@ To quickly bring up Fluent Bit with default values, use:
```console
osm install --enable-fluentbit
```
By default, logs will be filtered to emit info level logs. You may change the log level to "debug", "warn", "fatal", "panic", "disabled" or "trace" during installation using `--set OpenServiceMesh.controllerLogLevel=<desired log level>` . To get _all_ logs, set the log level to trace.

However, once you have tried this out, we recommend configuring log forwarding to your preferred output for more informative results.
Once you have tried out this basic setup, we recommend configuring log forwarding to your preferred output for more informative results.

To customize log forwarding to your output, follow these steps and then reinstall OSM with Fluent Bit enabled.

1. Find the output plugin you would like to forward your logs to in [Fluent Bit documentation](https://docs.fluentbit.io/manual/pipeline/outputs). Replace the `[OUTPUT]` section in [`fluentbit-configmap.yaml`](https://github.com/openservicemesh/osm/blob/main/charts/osm/templates/fluentbit-configmap.yaml) with appropriate values.

1. The default configuration uses CRI log format parsing. If you are using a kubernetes distribution that causes your logs to be formatted differently, you may need to add a new parser to the `[PARSER]` section and change the `parser` name in the `[INPUT]` section to one of the parsers defined [here](https://github.com/fluent/fluent-bit/blob/master/conf/parsers.conf).

1. The logs are currently filtered to match "error" level logs and multiple filters have been used to cover differences in log formatting on various Kubernetes distros.
* To change the log level being filtered on, you can update the `logLevel` value in [`values.yaml`](https://github.com/openservicemesh/osm/blob/main/charts/osm/values.yaml) to "debug", "info", "warn", "fatal", "panic", "disabled" or "trace".
* To view all logs irrespective of log level, you may remove the `[FILTER]` sections.
* The modify filter has been used to add a `controller_pod_name` key/value pair to help you query logs in your output by refining results on pod name (see example usage below).
* If you wish to apply further filtering, explore [Fluent Bit filters](https://docs.fluentbit.io/manual/pipeline/filters).
1. Explore available [Fluent Bit Filters](https://docs.fluentbit.io/manual/pipeline/filters) and add as many `[FILTER]` sections as desired.
* The `[INPUT]` section tags ingested logs with `kube.*` so make sure to include `Match kube.*` key/value pair in each of your custom filters.
* The default configuration uses a modify filter to add a `controller_pod_name` key/value pair to help you query logs in your output by refining results on pod name (see example usage below).

1. For these changes to take effect, run:
```console
Expand All @@ -43,7 +42,7 @@ To customize log forwarding to your output, follow these steps and then reinstal

1. Once you have updated the Fluent Bit ConfigMap template, you can deploy Fluent Bit during OSM installation using:
```console
osm install --enable-fluentbit
osm install --enable-fluentbit [--set OpenServiceMesh.controllerLogLevel=<desired log level>]
```
You should now be able to interact with error logs in the output of your choice as they get generated.

Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/e2e_fluentbit_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ var _ = OSMDescribe("Test deployment of Fluent Bit sidecar",
// Install OSM with Fluentbit
installOpts := Td.GetOSMInstallOpts()
installOpts.DeployFluentbit = true
installOpts.SetOverrides = []string{"OpenServiceMesh.fluentBit.logLevel=info"}
Expect(Td.InstallOSM(installOpts)).To(Succeed())

pods, err := Td.Client.CoreV1().Pods(Td.OsmNamespace).List(context.TODO(), metav1.ListOptions{
Expand All @@ -49,7 +48,6 @@ var _ = OSMDescribe("Test deployment of Fluent Bit sidecar",
Expect(err).ToNot(HaveOccurred(), "Unable to get container logs")
Expect(podLogs).To(ContainSubstring(logLevel))
Expect(podLogs).To(ContainSubstring("\"controller_pod_name\"=>\"osm-controller-"))
Expect(podLogs).NotTo(ContainSubstring("\"keep\"=>\"true\""))
}
}
}
Expand Down

0 comments on commit cdea8fd

Please sign in to comment.