Skip to content

Commit

Permalink
[promtail helm chart] Enable support for syslog service (#1617)
Browse files Browse the repository at this point in the history
* Enable support for dynamic extra ports

This should allow the chart to be configured for extra exposed ports
like syslog (port 1514) for example

Signed-off-by: Jeff Billimek <jeff@billimek.com>

* making syslog its own optional service

Signed-off-by: Jeff Billimek <jeff@billimek.com>

* syslogService config should be at top level

Signed-off-by: Jeff Billimek <jeff@billimek.com>

* fixing linting error

Signed-off-by: Jeff Billimek <jeff@billimek.com>

* Enhancing chart documentation with syslog example

Signed-off-by: Jeff Billimek <jeffrey_k_billimek@homedepot.com>
  • Loading branch information
billimek authored Feb 14, 2020
1 parent 460bb5b commit 9fe1f13
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 2 deletions.
24 changes: 24 additions & 0 deletions production/helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@ tls:
- {{ .Values.ingress.host }}
```

## Run promtail with syslog support

In order to receive and process syslog message into promtail, the following changes will be necessary:

* Review the [promtail syslog-receiver configuration documentation](/docs/clients/promtail/scraping.md#syslog-receiver)

* Configure the promtail helm chart with the syslog configuration added to the `extraScrapeConfigs` section and associated service definition to listen for syslog messages. For example:

```yaml
extraScrapeConfigs:
- job_name: syslog
syslog:
listen_address: 0.0.0.0:1514
labels:
job: "syslog"
relabel_configs:
- source_labels: ['__syslog_message_hostname']
target_label: 'host'
syslogService:
enabled: true
type: LoadBalancer
port: 1514
```
## How to contribute
After adding your new feature to the appropriate chart, you can build and deploy it locally to test:
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki-stack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: "v1"
name: loki-stack
version: 0.31.2
version: 0.32.0
appVersion: v1.3.0
kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs."
Expand Down
2 changes: 1 addition & 1 deletion production/helm/promtail/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: "v1"
name: promtail
version: 0.18.1
version: 0.19.0
appVersion: v1.3.0
kubeVersion: "^1.10.0-0"
description: "Responsible for gathering logs and sending them to Loki"
Expand Down
4 changes: 4 additions & 0 deletions production/helm/promtail/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ spec:
ports:
- containerPort: {{ .Values.config.server.http_listen_port }}
name: http-metrics
{{- if .Values.syslogService.enabled }}
- containerPort: {{ .Values.syslogService.port }}
name: syslog
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- if .Values.livenessProbe }}
Expand Down
42 changes: 42 additions & 0 deletions production/helm/promtail/templates/service-syslog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if .Values.syslogService.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "promtail.fullname" . }}-syslog
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "promtail.name" . }}
chart: {{ template "promtail.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.syslogService.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.syslogService.annotations | nindent 4 }}
spec:
type: {{ .Values.syslogService.type }}
{{- if (and (eq .Values.syslogService.type "ClusterIP") (not (empty .Values.syslogService.clusterIP))) }}
clusterIP: {{ .Values.syslogService.clusterIP }}
{{- end }}
{{- if .Values.syslogService.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- range $cidr := .Values.syslogService.loadBalancerSourceRanges }}
- {{ $cidr }}
{{- end }}
{{- end }}
ports:
- port: {{ .Values.syslogService.port }}
protocol: TCP
name: syslog
targetPort: syslog
{{- if (and (eq .Values.syslogService.type "NodePort") (not (empty .Values.syslogService.nodePort))) }}
nodePort: {{ .Values.syslogService.nodePort }}
{{- end }}
{{- if .Values.extraPorts }}
{{ toYaml .Values.extraPorts | indent 4}}
{{- end }}
selector:
app: {{ template "promtail.name" . }}
release: {{ .Release.Name }}
{{- end }}
24 changes: 24 additions & 0 deletions production/helm/promtail/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ config:

server:
http_listen_port: 3101

positions:
filename: /run/promtail/positions.yaml
target_config:
Expand All @@ -141,3 +142,26 @@ serviceMonitor:

# Extra env variables to pass to the promtail container
env: []

# enable and configure if using the syslog scrape config
syslogService:
enabled: false
type: ClusterIP
port: 1514
## Specify the nodePort value for the LoadBalancer and NodePort service types.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
##
# nodePort:
## Provide any additional annotations which may be required. This can be used to
## set the LoadBalancer service type to internal only.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
##
annotations: {}
labels: {}
## Use loadBalancerIP to request a specific static IP,
## otherwise leave blank
##
loadBalancerIP:
# loadBalancerSourceRanges: []
## Set the externalTrafficPolicy in the Service to either Cluster or Local
# externalTrafficPolicy: Cluster

0 comments on commit 9fe1f13

Please sign in to comment.