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 node-observ-lib #25

Merged
merged 9 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
109 changes: 109 additions & 0 deletions docs/node-observ-lib/README.md
Copy link
Member

Choose a reason for hiding this comment

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

Minor nitpicks throughout: I don't mind shortening observability to observ for the folder name, but it feels pretty awkward everywhere else

Copy link
Author

Choose a reason for hiding this comment

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

Good one, updated readme

Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Node exporter observ lib

This jsonnet observ lib can be used to generate observ package for node exporter.

## Import

```sh
jb init
jb install https://github.com/grafana/node_exporter/docs/node-observ-lib
```

## Examples

### Example 1: Basic example

You can use observ-lib to fill in monitoring-mixin structure:

```jsonnet
// mixin.libsonnet file
local nodelib = import 'node-observ-lib/main.libsonnet';

local linux =
nodelib.new(
filteringSelector='job="node"',
groupLabels=['job'],
instanceLabels=['instance'],
dashboardNamePrefix='Node exporter / ',
dashboardTags=['node-exporter-mixin'],
uid='node'
)
+ nodelib.withConfigMixin(
{
// enable loki logs
enableLokiLogs: true,
}
);

{
grafanaDashboards+:: linux.grafana.dashboards,
prometheusAlerts+:: linux.prometheus.alerts,
prometheusRules+:: linux.prometheus.recordingRules,
}

```

### Example 2: Modify specific panel before rendering dashboards

```jsonnet
local g = import './g.libsonnet';
// mixin.libsonnet file
local nodelib = import 'node-observ-lib/main.libsonnet';

local linux =
nodelib.new(
filteringSelector='job="node"',
groupLabels=['job'],
instanceLabels=['instance'],
dashboardNamePrefix='Node exporter / ',
dashboardTags=['node-exporter-mixin'],
uid='node'
)
+ {
grafana+: {
panels+: {
networkSockstatAll+:
+ g.panel.timeSeries.fieldConfig.defaults.custom.withDrawStyle('bars')
}
}
};

{
grafanaDashboards+:: linux.grafana.dashboards,
prometheusAlerts+:: linux.prometheus.alerts,
prometheusRules+:: linux.prometheus.recordingRules,
}

```

## Collectors used:

Grafana Agent or combination of node_exporter/promtail can be used in order to collect data required.

### Logs collection

Loki logs are used to populate logs dashboard and also for annotations.

To use logs, you need to opt-in, with setting `enableLokiLogs: true` in config.

See example above.

The following scrape snippet can be used in grafana-agent/promtail:

```yaml
- job_name: integrations/node_exporter_journal_scrape
journal:
max_age: 24h
labels:
instance: '<your-instance-name>'
job: integrations/node_exporter
relabel_configs:
- source_labels: ['__journal__systemd_unit']
target_label: 'unit'
- source_labels: ['__journal__boot_id']
target_label: 'boot_id'
- source_labels: ['__journal__transport']
target_label: 'transport'
- source_labels: ['__journal_priority_keyword']
target_label: 'level'
```
Loading