<p>So i have the following <a href="https://blog.openshift.com/wp-content/uploads/refarch-ocp-on-vmw-1.png" rel="nofollow noreferrer">Openshift/Origin architecture</a> installed following the official <a href="https://docs.openshift.org/3.6/install_config/install/advanced_install.html" rel="nofollow noreferrer">Openshift/Origin documentation</a>
We  also want to use the Aggregated logging setup that comes out of the box, that's why was set by using strictly the <a href="https://docs.openshift.com/container-platform/3.6/install_config/aggregate_logging.html" rel="nofollow noreferrer">Openshift aggregated logging</a> documentation. </p>

<p>So far the feedback has been excellent but i have another challenge for which i will need some help.
Developers want to specify by their own the log level that will be forwarded to the Elasticsearch. Current log level is set only thru FluentD.</p>

<p>Is there a way to set the log level by Deployment variable and make it pass Fluentd unchanged to Elasticsearch ?</p>

<p>The goal is to provide people a way to set by their own the log level that will be forwarded to Elasticsearch.</p>

<p>I afraid there is no way to do it by standard tools without adding a custom FluentD.</p>

<p>First of all, your FluentD in a cluster <a href="https://docs.openshift.com/container-platform/3.6/install_config/aggregate_logging.html#aggregated-fluentd" rel="nofollow noreferrer">reading a container logs</a> provided by Docker thru json-file logging <a href="https://docs.docker.com/config/containers/logging/json-file/" rel="nofollow noreferrer">driver</a>:</p>

<blockquote>
  <p>By default, Fluentd reads from /var/log/messages and /var/log/containers/.log for system logs and container logs, respectively.</p>
</blockquote>

<p>Even by using SystemD logging you will get the same result - logging level is set by Docker. Kubernetes <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/#logging-at-the-node-level" rel="nofollow noreferrer">also using</a> that driver.</p>

<p>For Docker json-file driver you can set <code>log-tags</code>, which, theoretically, can help you filter logs. But it is impossible to set that options for a container in runtime by Kubernetes, so there are now way.</p>

<p>The only way I see how you can do it is to use sidecar container <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/#sidecar-container-with-a-logging-agent" rel="nofollow noreferrer">with custom logging agent</a>. It will looks like that:</p>

<p><a href="https://i.stack.imgur.com/pKCSZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pKCSZ.png" alt="logging agent sidecar"></a> </p>

<p>Using sidecar, you can run FluentD with custom configuration inside it and parse a log of your application with any modification, including of using environment variables as a log level. </p>
