Skip to content

Commit

Permalink
Bugfix creating new queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Óscar Nájera committed Mar 28, 2022
1 parent a91ca14 commit e59e5b0
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 273 deletions.
56 changes: 44 additions & 12 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
This data-source plugin is a complete rewrite from the previous connector. It has
undergone a new architectural design and is not backwards compatible to the
previous version. We nevertheless provide an upgrade procedure to assist you on
the transition.
the transition.

This project has entered the Beta testing phase.

## Requirements

- Checkmk >= 2.0.0p20
- Grafana >= 7.0
- Grafana >= 8.0

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

## Getting started

### Installation

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


### Plugin configuration

URL
: URL of the Checkmk Server used.
: Example: http://checkmk.server/site/
Expand All @@ -64,13 +65,17 @@ reachable.

## Current state

- CEE configuration is now a filter based selection of graph templates of single metric.
- RAW configuration offers Service graphs and some single metrics.
This plugin offers 2 different interfaces, depending if you connect to an
Enterprise editions site or a RAW edition one.

- CEE interface is now a filter based selection for graph templates or single
metrics.
- RAW interface offers Service graphs and some single metrics.

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

### Combined graphs
### Filter base graph selection (Combined graphs, CEE)

- Construct combined graphs using traditional Checkmk filters. Currently available:
- Site filter
Expand All @@ -83,20 +88,34 @@ reachable.
- Service groups
- Host Tags

### Minor annoyances
### Static filter selection (Service Graphs, RAW)

Service graphs are defined by their specific descriptors for

- Site
- Hostname
- Service

## Minor annoyances

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

## Updating from the previous connector

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

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

# Maintenance

Code formatting

```BASH
yarn prettier --write src
```

Update dependencies

```BASH
yarn upgrade --latest
```
2 changes: 1 addition & 1 deletion dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"screenshots": [],
"version": "2.0.0",
"updated": "2022-02-03"
"updated": "2022-03-28"
},
"dependencies": {
"grafanaDependency": ">=7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@grafana/runtime": "^8.4.4",
"@grafana/toolkit": "^8.4.4",
"@grafana/ui": "^8.4.4",
"@testing-library/jest-dom": "5.16.2",
"@testing-library/jest-dom": "5.16.3",
"@testing-library/react": "^12.1.4",
"@types/lodash": "4.14.180"
},
Expand Down
17 changes: 11 additions & 6 deletions src/components/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import React from 'react';
import { AsyncSelect, InlineField, Select } from '@grafana/ui';
import { SelectableValue } from '@grafana/data';
import { AutoCompleteEditorProps, EditorProps } from './types';
import { get, update } from 'lodash';
import { get, update as _update, cloneDeep } from 'lodash';
import { DataSource } from '../DataSource';
import { combinedDesc } from 'graphspecs';

const update = (x: any, path: string, func: any) => {
let copy = cloneDeep(x);
_update(copy, path, func);
return copy;
};

export const vsAutocomplete = (datasource: DataSource, autocompleteConfig: any) => (inputValue: string) =>
datasource
.restRequest('ajax_vs_autocomplete.py', {
Expand All @@ -28,9 +34,9 @@ export const AsyncAutocomplete = ({
contextPath,
}: AutoCompleteEditorProps) => {
const onSelection = (value: SelectableValue<string>) => {
update(query, contextPath, () => value.value);
update(query, 'params.selections.' + contextPath, () => value);
onChange(query);
let newQuery = update(query, contextPath, () => value.value);
newQuery = update(newQuery, 'params.selections.' + contextPath, () => value);
onChange(newQuery);
onRunQuery();
};

Expand Down Expand Up @@ -61,8 +67,7 @@ export const GraphType = ({ query, onChange, onRunQuery, contextPath }: AutoComp
{ value: 'metric', label: 'Single metric' },
];
const onGraphTypeChange = (value: SelectableValue<string>) => {
update(query, contextPath, () => value.value);
onChange(query);
onChange(update(query, contextPath, () => value.value));
onRunQuery();
};

Expand Down

0 comments on commit e59e5b0

Please sign in to comment.