Skip to content

Commit e59e5b0

Browse files
author
Óscar Nájera
committed
Bugfix creating new queries
1 parent a91ca14 commit e59e5b0

File tree

7 files changed

+301
-273
lines changed

7 files changed

+301
-273
lines changed

dist/README.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
This data-source plugin is a complete rewrite from the previous connector. It has
66
undergone a new architectural design and is not backwards compatible to the
77
previous version. We nevertheless provide an upgrade procedure to assist you on
8-
the transition.
8+
the transition.
99

1010
This project has entered the Beta testing phase.
1111

1212
## Requirements
1313

1414
- Checkmk >= 2.0.0p20
15-
- Grafana >= 7.0
15+
- Grafana >= 8.0
1616

17-
This plugin release accompanies the Checkmk 2.1 release. You can use it already
18-
with Checkmk 2.0.0p20 for testing purposes, however bug-fixes, changes and
19-
updates will mainly take place on Checkmk 2.1 to not compromise the stability
20-
of Checkmk 2.0.
17+
This plugin release accompanies the checkmk 2.1 release. You can use it already
18+
with checkmk 2.0.0p20 for testing purposes, however bug-fixes, changes and
19+
updates will mainly take place on checkmk 2.1 to not compromise the stability
20+
of checkmk 2.0.
2121

2222
## Getting started
23+
2324
### Installation
2425

2526
Download the released version of this repository or clone it. Released versions
@@ -39,8 +40,8 @@ and you need to make sure this plugin is readable under those conditions. [Issue
3940
#52](https://github.com/tribe29/grafana-checkmk-datasource/issues/52#issuecomment-1026917446)
4041
includes troubleshooting information.
4142

42-
4343
### Plugin configuration
44+
4445
URL
4546
: URL of the Checkmk Server used.
4647
: Example: http://checkmk.server/site/
@@ -64,13 +65,17 @@ reachable.
6465

6566
## Current state
6667

67-
- CEE configuration is now a filter based selection of graph templates of single metric.
68-
- RAW configuration offers Service graphs and some single metrics.
68+
This plugin offers 2 different interfaces, depending if you connect to an
69+
Enterprise editions site or a RAW edition one.
70+
71+
- CEE interface is now a filter based selection for graph templates or single
72+
metrics.
73+
- RAW interface offers Service graphs and some single metrics.
6974

7075
- Dropped "Label Format" option. Prefer Grafana overrides.
7176
- Annotations are not available.
7277

73-
### Combined graphs
78+
### Filter base graph selection (Combined graphs, CEE)
7479

7580
- Construct combined graphs using traditional Checkmk filters. Currently available:
7681
- Site filter
@@ -83,20 +88,34 @@ reachable.
8388
- Service groups
8489
- Host Tags
8590

86-
### Minor annoyances
91+
### Static filter selection (Service Graphs, RAW)
92+
93+
Service graphs are defined by their specific descriptors for
94+
95+
- Site
96+
- Hostname
97+
- Service
98+
99+
## Minor annoyances
87100

88101
- When selecting a Filter. The focus jumps to the next Filter dropdown menu
89102
instead of the more intuitive focus on the selected filter itself.
90103
- Composed single metrics are not available anymore. E.g. from the Filesystem
91104
service "Free space" is a composed metric being the difference between "Total
92105
Size" and "Used Space".
106+
- Graphs that consist of a single metric(e.g. Uptime) appear on the Single
107+
metric graph type on the CEE interface, whereas there show up in duplication
108+
as a Template Type and a Single metric type on the RAW interface.
109+
- If connection to a checkmk 2.0 site.
110+
- Host & service dropdown options are not constrained by other active filters in the query.
111+
- Single metric graphs don't work on the RAW interface.
93112

94113
## Updating from the previous connector
95114

96115
We provide a Python script `utils/converter.py` which updates the Grafana
97116
SQLite database from the old connector setup to the new one. In that process it
98117
will go over all the dashboards and create a new version of them with the
99-
updated connector. PLEASE BACKUP THIS FILE BEFORE UPDATING.
118+
updated connector. **PLEASE BACKUP THIS FILE BEFORE UPDATING.**
100119

101120
1. Install and configure this new connector. Take note of the name you give it
102121
and take note of which name you gave the old connector. In this example we call them "Latest cmk connector" and "checkmk".
@@ -144,3 +163,16 @@ yarn watch
144163
yarn build
145164
```
146165

166+
# Maintenance
167+
168+
Code formatting
169+
170+
```BASH
171+
yarn prettier --write src
172+
```
173+
174+
Update dependencies
175+
176+
```BASH
177+
yarn upgrade --latest
178+
```

dist/module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
],
2222
"screenshots": [],
2323
"version": "2.0.0",
24-
"updated": "2022-02-03"
24+
"updated": "2022-03-28"
2525
},
2626
"dependencies": {
2727
"grafanaDependency": ">=7.0.0",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@grafana/runtime": "^8.4.4",
1818
"@grafana/toolkit": "^8.4.4",
1919
"@grafana/ui": "^8.4.4",
20-
"@testing-library/jest-dom": "5.16.2",
20+
"@testing-library/jest-dom": "5.16.3",
2121
"@testing-library/react": "^12.1.4",
2222
"@types/lodash": "4.14.180"
2323
},

src/components/fields.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ import React from 'react';
22
import { AsyncSelect, InlineField, Select } from '@grafana/ui';
33
import { SelectableValue } from '@grafana/data';
44
import { AutoCompleteEditorProps, EditorProps } from './types';
5-
import { get, update } from 'lodash';
5+
import { get, update as _update, cloneDeep } from 'lodash';
66
import { DataSource } from '../DataSource';
77
import { combinedDesc } from 'graphspecs';
88

9+
const update = (x: any, path: string, func: any) => {
10+
let copy = cloneDeep(x);
11+
_update(copy, path, func);
12+
return copy;
13+
};
14+
915
export const vsAutocomplete = (datasource: DataSource, autocompleteConfig: any) => (inputValue: string) =>
1016
datasource
1117
.restRequest('ajax_vs_autocomplete.py', {
@@ -28,9 +34,9 @@ export const AsyncAutocomplete = ({
2834
contextPath,
2935
}: AutoCompleteEditorProps) => {
3036
const onSelection = (value: SelectableValue<string>) => {
31-
update(query, contextPath, () => value.value);
32-
update(query, 'params.selections.' + contextPath, () => value);
33-
onChange(query);
37+
let newQuery = update(query, contextPath, () => value.value);
38+
newQuery = update(newQuery, 'params.selections.' + contextPath, () => value);
39+
onChange(newQuery);
3440
onRunQuery();
3541
};
3642

@@ -61,8 +67,7 @@ export const GraphType = ({ query, onChange, onRunQuery, contextPath }: AutoComp
6167
{ value: 'metric', label: 'Single metric' },
6268
];
6369
const onGraphTypeChange = (value: SelectableValue<string>) => {
64-
update(query, contextPath, () => value.value);
65-
onChange(query);
70+
onChange(update(query, contextPath, () => value.value));
6671
onRunQuery();
6772
};
6873

0 commit comments

Comments
 (0)