Last active
June 7, 2024 16:26
-
-
Save FutureSharks/ece4dbd233a421b3b2581eab92745697 to your computer and use it in GitHub Desktop.
Creates a Kubernetes DaemonSet that will monitor container logs and forward them to a Splunk Indexer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create using kubectl: | |
# $ kubectl create -f splunk-daemonset.yaml | |
# | |
# You should also add config on your indexer to deal with the json formatted files: | |
# https://answers.splunk.com/answers/148307/how-to-parse-and-extract-json-log-files-in-splunk.html | |
# | |
apiVersion: extensions/v1beta1 | |
kind: DaemonSet | |
metadata: | |
name: splunk-forwarder | |
spec: | |
template: | |
metadata: | |
labels: | |
name: splunk-forwarder | |
spec: | |
hostNetwork: true | |
containers: | |
- name: splunk-forwarder | |
image: splunk/universalforwarder:latest | |
env: | |
- name: SPLUNK_START_ARGS | |
value: "--accept-license" | |
- name: SPLUNK_FORWARD_SERVER | |
value: your_splunk_indexer:9997 | |
- name: SPLUNK_USER | |
value: root | |
- name: SPLUNK_ADD_1 | |
value: 'monitor /var/log/containers -sourcetype docker_json' | |
volumeMounts: | |
- mountPath: /var/log | |
name: varlog | |
readOnly: true | |
- mountPath: /var/lib/docker/containers | |
name: varlibdockercontainers | |
readOnly: true | |
terminationGracePeriodSeconds: 30 | |
volumes: | |
- hostPath: | |
path: /var/log | |
name: varlog | |
- hostPath: | |
path: /var/lib/docker/containers | |
name: varlibdockercontainers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was able to add custom configuration by adding
command
andargs
as follows:It's a bit hacky but allows you to avoid building a custom Docker image.