Skip to content

Commit

Permalink
Use loki in k3d agent DS instead of promtail (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfratto authored Feb 10, 2021
1 parent 4ab580e commit aaaa652
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 361 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ can be found at [#317](https://github.com/grafana/agent/issues/317).
longer report an error and will instead use the pre-existing default value.
(@rfratto)

- [BUGFIX] Fixed a bug from v0.12.0 where the Loki installation script failed
because positions_directory was not set. (@rfratto)

# v0.12.0 (2021-02-05)

BREAKING CHANGES: This release has two breaking changes in the configuration
Expand Down
9 changes: 8 additions & 1 deletion example/k3d/environment/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local agent_cluster = import 'grafana-agent/scraping-svc/main.libsonnet';
local k = import 'ksonnet-util/kausal.libsonnet';

local grafana_agent = import 'grafana-agent/v1/main.libsonnet';
local loki_config = import 'default/loki_config.libsonnet';

local service = k.core.v1.service;
local images = {
Expand Down Expand Up @@ -51,7 +52,13 @@ local images = {
}) +
grafana_agent.withRemoteWrite([{
url: 'http://cortex.default.svc.cluster.local/api/prom/push',
}]),
}]) +
grafana_agent.withLokiConfig(loki_config) +
grafana_agent.withLokiClients(grafana_agent.newLokiClient({
scheme: 'http',
hostname: 'loki.default.svc.cluster.local',
external_labels: { cluster: cluster_label },
})),

// Need to run ETCD for agent_cluster
etcd: etcd.new('default'),
Expand Down
9 changes: 0 additions & 9 deletions example/k3d/jsonnetfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
},
"version": "master"
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/loki",
"subdir": "production/ksonnet/promtail"
}
},
"version": "master"
},
{
"source": {
"git": {
Expand Down
10 changes: 0 additions & 10 deletions example/k3d/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@
"version": "b9cc0f3529833096c043084c04bc7b3562a134c4",
"sum": "mtTAh8vSa4Eb8ojviyZ9zE2pPq5OgwhK75qsEWkifhI="
},
{
"source": {
"git": {
"remote": "https://github.com/grafana/loki.git",
"subdir": "production/ksonnet/promtail"
}
},
"version": "10a1f28a85b5506c662688611442d31867fe2bc0",
"sum": "MOoAhHzLkR7NSqD7ZVqjlcSDNRUz3fVgJQiYM1hd+us="
},
{
"source": {
"git": {
Expand Down
41 changes: 41 additions & 0 deletions example/k3d/lib/default/loki_config.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
local grafana_agent = import 'grafana-agent/v1/main.libsonnet';

grafana_agent.scrapeKubernetesLogs {
local pipeline_stages = [
// k3d uses cri for logging
{ cri: {} },

// Bad words metrics, used in Agent dashboard
{
regex: {
expression: '(?i)(?P<bad_words>panic:|core_dumped|failure|error|attack| bad |illegal |denied|refused|unauthorized|fatal|failed|Segmentation Fault|Corrupted)',
},
},
{
metrics: {
panic_total: {
type: 'Counter',
description: 'total count of panic: found in log lines',
source: 'panic',
config: {
action: 'inc',
},
},
bad_words_total: {
type: 'Counter',
description: 'total count of bad words found in log lines',
source: 'bad_words',
config: {
action: 'inc',
},
},
},
},
],

scrape_configs: [
x { pipeline_stages: pipeline_stages }
for x
in super.scrape_configs
],
}
46 changes: 0 additions & 46 deletions example/k3d/lib/default/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ local grafana = import 'grafana/main.libsonnet';
local k = import 'ksonnet-util/kausal.libsonnet';
local loki = import 'loki/main.libsonnet';
local metrics = import 'metrics-server/main.libsonnet';
local promtail = import 'promtail/promtail.libsonnet';

local mixins = import './mixins.libsonnet';

Expand All @@ -22,51 +21,6 @@ local mixins = import './mixins.libsonnet';

loki: loki.new(namespace),

promtail: promtail {
_config+:: {
namespace: namespace,
promtail_config+: {
clients: [{
scheme:: 'http',
hostname:: 'loki.default.svc.cluster.local',
external_labels: {},
}],

pipeline_stages: [
// k3d uses cri for logging
{ cri: {} },

// Bad words metrics, used in Agent dashboard
{
regex: {
expression: '(?i)(?P<bad_words>panic:|core_dumped|failure|error|attack| bad |illegal |denied|refused|unauthorized|fatal|failed|Segmentation Fault|Corrupted)',
},
},
{
metrics: {
panic_total: {
type: 'Counter',
description: 'total count of panic: found in log lines',
source: 'panic',
config: {
action: 'inc',
},
},
bad_words_total: {
type: 'Counter',
description: 'total count of bad words found in log lines',
source: 'bad_words',
config: {
action: 'inc',
},
},
},
},
],
},
},
},

cortex: cortex.new(namespace),
},
}
3 changes: 2 additions & 1 deletion example/k3d/scripts/create.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ k3d create \
--name agent-k3d \
--publish 30080:30080 \
--api-port 50443 \
-v /var/lib/k3d/agent-k3d/storage/:/var/lib/rancher/k3s/storage/
-v /var/lib/k3d/agent-k3d/storage/:/var/lib/rancher/k3s/storage/ \
-v /etc/machine-id:/etc/machine-id

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit aaaa652

Please sign in to comment.