Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fluent-bit and VictoriaLogs #305

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/extra/monitoring/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name: monitoring
description: Monitoring and observability stack
icon: /logos/monitoring.svg
type: application
version: 1.3.0
version: 1.4.0
23 changes: 23 additions & 0 deletions packages/extra/monitoring/templates/grafana/grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,34 @@ spec:
security:
admin_user: user
admin_password: ${GF_PASSWORD}
plugins:
allow_loading_unsigned_plugins: "victorialogs-datasource"
deployment:
spec:
replicas: 2
template:
spec:
initContainers:
- name: "load-vm-ds-plugin"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to build custom image as there could be no internet access (prepare for airgap)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just use a VolumeSource from the latest kubernetes and use the power of OCI

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, I'll add an issue for this #306

image: "curlimages/curl:7.85.0"
command: [ "/bin/sh" ]
workingDir: "/var/lib/grafana"
securityContext:
runAsUser: 10001
runAsNonRoot: true
runAsGroup: 10001
args:
- "-c"
- |
set -ex
mkdir -p /var/lib/grafana/plugins/
ver=$(curl -s https://api.github.com/repos/VictoriaMetrics/victorialogs-datasource/releases/latest | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
curl -L https://github.com/VictoriaMetrics/victorialogs-datasource/releases/download/$ver/victorialogs-datasource-$ver.tar.gz -o /var/lib/grafana/plugins/vl-plugin.tar.gz
tar -xf /var/lib/grafana/plugins/vl-plugin.tar.gz -C /var/lib/grafana/plugins/
rm /var/lib/grafana/plugins/vl-plugin.tar.gz
volumeMounts:
- name: grafana-data
mountPath: /var/lib/grafana
containers:
- name: grafana
image: grafana/grafana:10.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ spec:
reconcileStrategy: Revision
sourceRef:
kind: HelmRepository
name: cozystack-extra
namespace: cozy-public
version: 0.1.0
name: cozystack-system
namespace: cozy-system
version: '*'
interval: 1m0s
timeout: 5m0s
values:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- range .Values.logsStorages }}
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDatasource
metadata:
name: vlog-{{ .name }}
spec:
datasource:
access: proxy
type: victorialogs-datasource
name: vlog-{{ .name }}
url: http://vlog-{{ .name }}-0.vlog-{{ .name }}.{{ $.Release.Namespace }}.svc:9428
instanceSelector:
matchLabels:
dashboards: grafana
{{- end }}
31 changes: 31 additions & 0 deletions packages/extra/monitoring/templates/vlogs/vlogs-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- range .Values.logsStorages }}
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: vlog-{{ .name }}-system
labels:
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
chart:
spec:
chart: cozy-victoria-logs
reconcileStrategy: Revision
sourceRef:
kind: HelmRepository
name: cozystack-system
namespace: cozy-system
version: '*'
interval: 1m0s
timeout: 5m0s
values:
global:
victoriaLogs:
server:
fullnameOverride: vlog-{{ .name }}
kvaps marked this conversation as resolved.
Show resolved Hide resolved
victoria-logs-single:
server:
persistentVolume:
kvaps marked this conversation as resolved.
Show resolved Hide resolved
enabled: true
size: 10Gi
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDatasource
metadata:
name: {{ .name }}
name: vm-{{ .name }}
spec:
instanceSelector:
matchLabels:
dashboards: grafana
datasource:
name: {{ .name }}
name: vm-{{ .name }}
type: prometheus
access: proxy
url: http://vmselect-{{ .name }}.{{ $.Release.Namespace }}.svc:8481/select/0/prometheus/
Expand Down
8 changes: 8 additions & 0 deletions packages/extra/monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ metricsStorages:
storage: 10Gi
storageClassName: ""

## @param metricsStorages [array] Configuration of logs storage instances
##
logsStorages:
- name: generic
retentionPeriod: "1m"
storage: 10Gi
storageClassName: replicated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default it uses replicated storageClass, due to fact vlog can't run as cluster for now


## @param oncall.enabled Enable Grafana OnCall
##
oncall:
Expand Down
4 changes: 4 additions & 0 deletions packages/system/monitoring/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ update:
helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
helm repo update metrics-server
helm pull metrics-server/metrics-server --untar --untardir charts
# Fluent-bit
helm repo add fluent https://fluent.github.io/helm-charts
helm repo update fluent
helm pull fluent/fluent-bit --untar --untardir charts
23 changes: 23 additions & 0 deletions packages/system/monitoring/charts/fluent-bit/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
27 changes: 27 additions & 0 deletions packages/system/monitoring/charts/fluent-bit/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
annotations:
artifacthub.io/changes: |
- kind: changed
description: "Updated Fluent Bit OCI image to v3.1.6."
apiVersion: v1
appVersion: 3.1.6
description: Fast and lightweight log processor and forwarder or Linux, OSX and BSD
family operating systems.
home: https://fluentbit.io/
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/fluentd/fluentbit/icon/fluentbit-icon-color.svg
keywords:
- logging
- fluent-bit
- fluentd
maintainers:
- email: [email protected]
name: edsiper
- email: [email protected]
name: naseemkullah
- email: [email protected]
name: Towmeykaw
- email: [email protected]
name: stevehipwell
name: fluent-bit
sources:
- https://github.com/fluent/fluent-bit/
version: 0.47.7
57 changes: 57 additions & 0 deletions packages/system/monitoring/charts/fluent-bit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Fluent Bit Helm chart

[Fluent Bit](https://fluentbit.io) is a fast and lightweight log processor and forwarder or Linux, OSX and BSD family operating systems.

## Installation

To add the `fluent` helm repo, run:

```sh
helm repo add fluent https://fluent.github.io/helm-charts
```

To install a release named `fluent-bit`, run:

```sh
helm install fluent-bit fluent/fluent-bit
```

## Chart values

```sh
helm show values fluent/fluent-bit
```

## Using Lua scripts
Fluent Bit allows us to build filter to modify the incoming records using custom [Lua scripts.](https://docs.fluentbit.io/manual/pipeline/filters/lua)

### How to use Lua scripts with this Chart

First, you should add your Lua scripts to `luaScripts` in values.yaml, for example:

```yaml
luaScripts:
filter_example.lua: |
function filter_name(tag, timestamp, record)
-- put your lua code here.
end
```

After that, the Lua scripts will be ready to be used as filters. So next step is to add your Fluent bit [filter](https://docs.fluentbit.io/manual/concepts/data-pipeline/filter) to `config.filters` in values.yaml, for example:

```yaml
config:
filters: |
[FILTER]
Name lua
Match <your-tag>
script /fluent-bit/scripts/filter_example.lua
call filter_name
```
Under the hood, the chart will:
- Create a configmap using `luaScripts`.
- Add a volumeMounts for each Lua scripts using the path `/fluent-bit/scripts/<script>`.
- Add the Lua script's configmap as volume to the pod.

### Note
Remember to set the `script` attribute in the filter using `/fluent-bit/scripts/`, otherwise the file will not be found by fluent bit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
testFramework:
enabled: true

logLevel: debug

dashboards:
enabled: true
Loading