f99c58f7bb
* build(deps): bump @fortawesome/react-fontawesome from 0.1.17 to 0.2.0 in /web/ui * build(deps): bump go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp Bumps [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib) from 0.36.0 to 0.36.4. - [Release notes](https://github.com/open-telemetry/opentelemetry-go-contrib/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go-contrib/compare/zpages/v0.36.0...zpages/v0.36.4) --- updated-dependencies: - dependency-name: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update snapshots Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthieu MOREL <matthieu.morel35@gmail.com> * build(deps-dev): bump sinon from 13.0.2 to 14.0.1 in /web/ui Bumps [sinon](https://github.com/sinonjs/sinon) from 13.0.2 to 14.0.1. - [Release notes](https://github.com/sinonjs/sinon/releases) - [Changelog](https://github.com/sinonjs/sinon/blob/main/docs/changelog.md) - [Commits](https://github.com/sinonjs/sinon/compare/v13.0.2...v14.0.1) --- updated-dependencies: - dependency-name: sinon dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump @codemirror/view from 6.3.0 to 6.4.0 in /web/ui Bumps [@codemirror/view](https://github.com/codemirror/view) from 6.3.0 to 6.4.0. - [Release notes](https://github.com/codemirror/view/releases) - [Changelog](https://github.com/codemirror/view/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/view/compare/6.3.0...6.4.0) --- updated-dependencies: - dependency-name: "@codemirror/view" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump actions/cache from 3.0.9 to 3.0.11 Bumps [actions/cache](https://github.com/actions/cache) from 3.0.9 to 3.0.11. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.9...v3.0.11) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump bufbuild/buf-setup-action from 1.8.0 to 1.9.0 Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.8.0 to 1.9.0. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.8.0...v1.9.0) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update dependabot.yml Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> * build(deps): bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.13.0 to 1.13.1. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/v1.13.1/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.13.0...v1.13.1) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/stretchr/testify Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.0 to 1.8.1. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.8.0...v1.8.1) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/ovh/go-ovh from 1.1.0 to 1.3.0 Bumps [github.com/ovh/go-ovh](https://github.com/ovh/go-ovh) from 1.1.0 to 1.3.0. - [Release notes](https://github.com/ovh/go-ovh/releases) - [Commits](https://github.com/ovh/go-ovh/compare/v1.1.0...v1.3.0) --- updated-dependencies: - dependency-name: github.com/ovh/go-ovh dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump @lezer/highlight from 1.1.1 to 1.1.2 in /web/ui Bumps [@lezer/highlight](https://github.com/lezer-parser/highlight) from 1.1.1 to 1.1.2. - [Release notes](https://github.com/lezer-parser/highlight/releases) - [Changelog](https://github.com/lezer-parser/highlight/blob/main/CHANGELOG.md) - [Commits](https://github.com/lezer-parser/highlight/compare/1.1.1...1.1.2) --- updated-dependencies: - dependency-name: "@lezer/highlight" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump @forevolve/bootstrap-dark in /web/ui Bumps [@forevolve/bootstrap-dark](https://github.com/ForEvolve/bootstrap-dark) from 1.1.0 to 2.1.1. - [Release notes](https://github.com/ForEvolve/bootstrap-dark/releases) - [Commits](https://github.com/ForEvolve/bootstrap-dark/compare/v1.1.0...v2.1.1) --- updated-dependencies: - dependency-name: "@forevolve/bootstrap-dark" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/digitalocean/godo from 1.88.0 to 1.89.0 Bumps [github.com/digitalocean/godo](https://github.com/digitalocean/godo) from 1.88.0 to 1.89.0. - [Release notes](https://github.com/digitalocean/godo/releases) - [Changelog](https://github.com/digitalocean/godo/blob/main/CHANGELOG.md) - [Commits](https://github.com/digitalocean/godo/compare/v1.88.0...v1.89.0) --- updated-dependencies: - dependency-name: github.com/digitalocean/godo dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump sanitize-html from 2.7.2 to 2.7.3 in /web/ui Bumps [sanitize-html](https://github.com/apostrophecms/sanitize-html) from 2.7.2 to 2.7.3. - [Release notes](https://github.com/apostrophecms/sanitize-html/releases) - [Changelog](https://github.com/apostrophecms/sanitize-html/blob/main/CHANGELOG.md) - [Commits](https://github.com/apostrophecms/sanitize-html/compare/2.7.2...2.7.3) --- updated-dependencies: - dependency-name: sanitize-html dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps-dev): bump ts-jest from 27.1.5 to 29.0.3 in /web/ui (#70) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 27.1.5 to 29.0.3. - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/kulshekhar/ts-jest/compare/v27.1.5...v29.0.3) --- updated-dependencies: - dependency-name: ts-jest dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump moment-timezone from 0.5.37 to 0.5.38 in /web/ui Bumps [moment-timezone](https://github.com/moment/moment-timezone) from 0.5.37 to 0.5.38. - [Release notes](https://github.com/moment/moment-timezone/releases) - [Changelog](https://github.com/moment/moment-timezone/blob/develop/changelog.md) - [Commits](https://github.com/moment/moment-timezone/compare/0.5.37...0.5.38) --- updated-dependencies: - dependency-name: moment-timezone dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump downshift from 6.1.12 to 7.0.1 in /web/ui Bumps [downshift](https://github.com/downshift-js/downshift) from 6.1.12 to 7.0.1. - [Release notes](https://github.com/downshift-js/downshift/releases) - [Changelog](https://github.com/downshift-js/downshift/blob/master/CHANGELOG.md) - [Commits](https://github.com/downshift-js/downshift/compare/v6.1.12...v7.0.1) --- updated-dependencies: - dependency-name: downshift dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump @codemirror/commands from 6.1.1 to 6.1.2 in /web/ui Bumps [@codemirror/commands](https://github.com/codemirror/commands) from 6.1.1 to 6.1.2. - [Release notes](https://github.com/codemirror/commands/releases) - [Changelog](https://github.com/codemirror/commands/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/commands/compare/6.1.1...6.1.2) --- updated-dependencies: - dependency-name: "@codemirror/commands" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump @fortawesome/fontawesome-svg-core in /web/ui Bumps [@fortawesome/fontawesome-svg-core](https://github.com/FortAwesome/Font-Awesome) from 6.1.1 to 6.2.0. - [Release notes](https://github.com/FortAwesome/Font-Awesome/releases) - [Changelog](https://github.com/FortAwesome/Font-Awesome/blob/6.x/CHANGELOG.md) - [Commits](https://github.com/FortAwesome/Font-Awesome/compare/6.1.1...6.2.0) --- updated-dependencies: - dependency-name: "@fortawesome/fontawesome-svg-core" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump sass from 1.54.9 to 1.56.0 in /web/ui Bumps [sass](https://github.com/sass/dart-sass) from 1.54.9 to 1.56.0. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.54.9...1.56.0) --- updated-dependencies: - dependency-name: sass dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump @codemirror/search from 6.2.1 to 6.2.2 in /web/ui Bumps [@codemirror/search](https://github.com/codemirror/search) from 6.2.1 to 6.2.2. - [Release notes](https://github.com/codemirror/search/releases) - [Changelog](https://github.com/codemirror/search/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/search/compare/6.2.1...6.2.2) --- updated-dependencies: - dependency-name: "@codemirror/search" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps-dev): bump @types/jest from 27.5.2 to 29.2.1 in /web/ui Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 27.5.2 to 29.2.1. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump @codemirror/language from 6.2.1 to 6.3.0 in /web/ui Bumps [@codemirror/language](https://github.com/codemirror/language) from 6.2.1 to 6.3.0. - [Release notes](https://github.com/codemirror/language/releases) - [Changelog](https://github.com/codemirror/language/blob/main/CHANGELOG.md) - [Commits](https://github.com/codemirror/language/compare/6.2.1...6.3.0) --- updated-dependencies: - dependency-name: "@codemirror/language" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump react-resize-detector from 6.7.8 to 7.1.2 in /web/ui * build(deps): bump react-resize-detector from 6.7.8 to 7.1.2 in /web/ui Bumps [react-resize-detector](https://github.com/maslianok/react-resize-detector) from 6.7.8 to 7.1.2. - [Release notes](https://github.com/maslianok/react-resize-detector/releases) - [Commits](https://github.com/maslianok/react-resize-detector/commits) --- updated-dependencies: - dependency-name: react-resize-detector dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * remove @types/react-resize-detector Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> * npm i --package-lock-only Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthieu MOREL <matthieu.morel35@gmail.com> * build(deps): bump @fortawesome/free-solid-svg-icons from 6.1.1 to 6.2.0 in /web/ui * build(deps): bump go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp Bumps [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib) from 0.36.0 to 0.36.4. - [Release notes](https://github.com/open-telemetry/opentelemetry-go-contrib/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go-contrib/compare/zpages/v0.36.0...zpages/v0.36.4) --- updated-dependencies: - dependency-name: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * update snapshot Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthieu MOREL <matthieu.morel35@gmail.com> * build(deps): bump github.com/aws/aws-sdk-go from 1.44.128 to 1.44.131 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.128 to 1.44.131. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.128...v1.44.131) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/envoyproxy/protoc-gen-validate Bumps [github.com/envoyproxy/protoc-gen-validate](https://github.com/envoyproxy/protoc-gen-validate) from 0.6.13 to 0.8.0. - [Release notes](https://github.com/envoyproxy/protoc-gen-validate/releases) - [Changelog](https://github.com/bufbuild/protoc-gen-validate/blob/main/.goreleaser.yaml) - [Commits](https://github.com/envoyproxy/protoc-gen-validate/compare/v0.6.13...v0.8.0) --- updated-dependencies: - dependency-name: github.com/envoyproxy/protoc-gen-validate dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps-dev): bump @types/jest from 29.2.1 to 29.2.2 in /web/ui Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.2.1 to 29.2.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * rollback to default value for open-pull-requests-limit Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
---|---|---|
.. | ||
src | ||
.eslintrc.json | ||
.gitignore | ||
.npmignore | ||
build.sh | ||
jest.config.cjs | ||
package.json | ||
README.md | ||
setupJest.cjs | ||
tsconfig.json |
CodeMirror-promql
This project provides a mode for CodeMirror Next that handles syntax highlighting, linting and autocompletion for PromQL (Prometheus Query Language).
Installation
This mode is available as a npm package:
npm install --save @prometheus-io/codemirror-promql
Note: You will have to manually install different packages that are part of CodeMirror Next, as they are a peer dependency to this package. Here are the different packages you need to install:
- @codemirror/autocomplete
- @codemirror/language
- @codemirror/lint
- @codemirror/state
- @codemirror/view
- @lezer/common
npm install --save @codemirror/autocomplete @codemirror/language @codemirror/lint @codemirror/state @codemirror/view @lezer/common
Note 2: that's the minimum required to install the lib. You would probably need to install as well the dependency @codemirror/basic-setup to ease the setup of codeMirror itself:
npm install --save @codemirror/basic-setup
Usage
As the setup of the PromQL language can a bit tricky in CMN, this lib provides a class PromQLExtension
which is here to help you to configure the different extensions we aim to provide.
Default setup
If you want to enjoy about the different features provided without taking too much time to understand how to configure them, then the easiest way is this one:
import {PromQLExtension} from '@prometheus-io/codemirror-promql';
import {basicSetup} from '@codemirror/basic-setup';
import {EditorState} from '@codemirror/state';
import {EditorView} from '@codemirror/view';
const promQL = new PromQLExtension()
new EditorView({
state: EditorState.create({
extensions: [basicSetup, promQL.asExtension()],
}),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
// tslint:disable-next-line:no-non-null-assertion
parent: document.getElementById('editor')!,
});
Using the default setup will activate:
- syntax highlighting
- an offline autocompletion that will suggest PromQL keywords such as functions / aggregations, depending on the context.
- an offline linter that will display PromQL syntax errors (which is closer to what Prometheus returns)
Deactivate autocompletion - linter
In case you would like to deactivate the linter and/or the autocompletion it's simple as that:
const promQL = new PromQLExtension().activateLinter(false).activateCompletion(false) // here the linter and the autocomplete are deactivated
Linter
There is no particular configuration today for the linter. Feel free to file an issue if you have some use cases that would require configurability.
Autocompletion
The autocompletion feature provides multiple different parameters that can be used to adapt this lib to your environment.
maxMetricsMetadata
maxMetricsMetadata
is the maximum number of metrics in Prometheus for which metadata is fetched. If the number of
metrics exceeds this limit, no metric metadata is fetched at all.
By default, the limit is 10 000 metrics.
Use it cautiously. A high value of this limit can cause a crash of your browser due to too many data fetched.
const promQL = new PromQLExtension().setComplete({maxMetricsMetadata: 10000})
Connect the autocompletion extension to a remote Prometheus server
Connecting the autocompletion extension to a remote Prometheus server will provide autocompletion of metric names, label names, and label values.
Use the default Prometheus client
Prometheus URL
If you want to use the default Prometheus client provided by this lib, you have to provide the url used to contact the Prometheus server.
Note: this is the only mandatory parameter in case you want to use the default Prometheus client. Without this parameter, the rest of the config will be ignored, and the Prometheus client won't be initialized.
const promQL = new PromQLExtension().setComplete({remote: {url: 'https://prometheus.land'}})
Override FetchFn
In case your Prometheus server is protected and requires a special HTTP client, you can override the function fetchFn
that is used to perform any required HTTP request.
const promQL = new PromQLExtension().setComplete({remote: {fetchFn: myHTTPClient}})
Duration to use for looking back when retrieving metrics / labels
If you are a bit familiar with the Prometheus API, you are aware that you can pass a time interval that is used to tell to Prometheus which period of time you are looking for when retrieving metadata (like metrics / labels).
In case you would like to provide your own duration, you can override the variable lookbackInterval
. By default, the
value is 12 * 60 * 60 * 1000
(12h). The value must be defined in milliseconds.
const promQL = new PromQLExtension().setComplete({remote: {lookbackInterval: 12 * 60 * 60 * 1000}})
Error Handling
You can set up your own error handler to catch any HTTP error that can occur when the PrometheusClient is contacting Prometheus.
const promQL = new PromQLExtension().setComplete({remote: {httpErrorHandler: (error: any) => console.error(error)}})
HTTP method used
By default, the Prometheus client will use the HTTP method POST
when contacting Prometheus for the
endpoints /api/v1/labels
and /api/v1/series
.
You can change it to use the HTTP method GET
if you prefer.
const promQL = new PromQLExtension().setComplete({remote: {httpMethod: 'GET'}})
Override the API Prefix
The default Prometheus Client, when building the query to get data from Prometheus, is using an API prefix which is by
default /api/v1
.
You can override this value like this:
const promql = new PromQLExtension().setComplete({remote: {apiPrefix: '/my/api/prefix'}})
Cache
The default client has an embedded cache that is used to store the different metrics and labels retrieved from a remote Prometheus server.
Max Age
The data are stored in the cache for a limited amount of time defined by the variable maxAge
which is by default 5
minutes. The value must be defined in milliseconds.
const promQL = new PromQLExtension().setComplete({remote: {cache: {maxAge: 5 * 60 * 1000}}})
Initial Metric List
The cache can be initialized with a list of metric names. It is useful when you already have the list of the metrics
somewhere else in your application, and you would like to share this list with the embedded Prometheus client
of codemirror-promql
.
Note: keep in mind that this list will be kept into the embedded Prometheus client until the time defined by maxAge
.
const promQL = new PromQLExtension().setComplete({
remote: {
cache: {
initialMetricList: [
'ALERTS',
'ALERTS_FOR_STATE',
'alertmanager_alerts',
'alertmanager_alerts_invalid_total',
'alertmanager_alerts_received_total',
]
}
}
})
Override the default Prometheus client
In case you are not satisfied by our default Prometheus client, you can still provide your own. It has to implement the interface PrometheusClient .
const promQL = new PromQLExtension().setComplete({remote: MyPrometheusClient})
Provide your own implementation of the autocompletion
In case you would like to provide you own implementation of the autocompletion, you can simply do it like that:
const promQL = new PromQLExtension().setComplete({completeStrategy: myCustomImpl})
Note: In case this parameter is provided, then the rest of the configuration is ignored.
Example
License
The code is licensed under an Apache 2.0 license.