mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Add readme for lezer-promql and update codemirror-promql readme (#10875)
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
parent
04fe2c9522
commit
87ffac3e9d
|
@ -1,27 +1,17 @@
|
|||
CodeMirror-promql
|
||||
=================
|
||||
[](https://circleci.com/gh/prometheus/codemirror-promql) [](./LICENSE)
|
||||
[](https://www.npmjs.org/package/codemirror-promql) [](https://codecov.io/gh/prometheus/codemirror-promql)
|
||||
|
||||
## Overview
|
||||
|
||||
This project provides a mode for [CodeMirror Next](https://codemirror.net/6) that handles syntax highlighting, linting
|
||||
and autocompletion for PromQL ([Prometheus Query Language](https://prometheus.io/docs/introduction/overview/)).
|
||||
|
||||

|
||||
|
||||
## Where does it come from?
|
||||
|
||||
The authoritative copy of this code lives in `prometheus/prometheus` and is synced to
|
||||
`prometheus/codemirror-promql` on a regular basis by a bot. Please contribute any code changes to the code
|
||||
in https://github.com/prometheus/prometheus/tree/main/web/ui/module/codemirror-promql.
|
||||
|
||||
### Installation
|
||||
## Installation
|
||||
|
||||
This mode is available as a npm package:
|
||||
|
||||
```bash
|
||||
npm install --save codemirror-promql
|
||||
npm install --save @prometheus-io/codemirror-promql
|
||||
```
|
||||
|
||||
**Note:** You will have to manually install different packages that are part
|
||||
|
@ -29,14 +19,14 @@ of [CodeMirror Next](https://codemirror.net/6), as they are a peer dependency to
|
|||
packages you need to install:
|
||||
|
||||
* **@codemirror/autocomplete**
|
||||
* **@codemirror/highlight**
|
||||
* **@codemirror/language**
|
||||
* **@codemirror/lint**
|
||||
* **@codemirror/state**
|
||||
* **@codemirror/view**
|
||||
* **@lezer/common**
|
||||
|
||||
```bash
|
||||
npm install --save @codemirror/autocomplete @codemirror/highlight @codemirror/language @codemirror/lint @codemirror/state @codemirror/view
|
||||
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
|
||||
|
@ -57,7 +47,7 @@ If you want to enjoy about the different features provided without taking too mu
|
|||
them, then the easiest way is this one:
|
||||
|
||||
```typescript
|
||||
import { PromQLExtension } from 'codemirror-promql';
|
||||
import {PromQLExtension} from '@prometheus-io/codemirror-promql';
|
||||
import {basicSetup} from '@codemirror/basic-setup';
|
||||
import {EditorState} from '@codemirror/state';
|
||||
import {EditorView} from '@codemirror/view';
|
||||
|
@ -173,7 +163,8 @@ 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`.
|
||||
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:
|
||||
|
||||
|
@ -246,4 +237,4 @@ Note: In case this parameter is provided, then the rest of the configuration is
|
|||
|
||||
## License
|
||||
|
||||
Apache License 2.0, see [LICENSE](https://github.com/prometheus/codemirror-promql/blob/main/LICENSE).
|
||||
The code is licensed under an [Apache 2.0](https://github.com/prometheus/prometheus/blob/main/LICENSE) license.
|
||||
|
|
43
web/ui/module/lezer-promql/README.md
Normal file
43
web/ui/module/lezer-promql/README.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
# lezer-promql
|
||||
|
||||
## Overview
|
||||
|
||||
This is a PromQL grammar for the [lezer](https://lezer.codemirror.net/) parser system. It is inspired by the initial
|
||||
grammar coming from [Prometheus](https://github.com/prometheus/prometheus/blob/main/promql/parser/generated_parser.y)
|
||||
written in yacc.
|
||||
|
||||
This library is stable but doesn't provide any guideline of how to use it as it has been integrated
|
||||
into [codemirror-promql](https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql). If you
|
||||
want to use this library, you perhaps want to actually use **@prometheus-io/codemirror-promql** instead.
|
||||
|
||||
**Note**: This library is a lezer-based implementation of the [authoritative, goyacc-based PromQL grammar](https://github.com/prometheus/prometheus/blob/main/promql/parser/generated_parser.y).
|
||||
Any changes to the authoritative grammar need to be reflected in this package as well.
|
||||
|
||||
## Installation
|
||||
|
||||
This package is available as an npm package:
|
||||
|
||||
```bash
|
||||
npm install --save @prometheus-io/lezer-promql
|
||||
```
|
||||
|
||||
**Note**: you will have to manually install the `lezer` dependencies as it is a peer dependency to this package.
|
||||
|
||||
```bash
|
||||
npm install --save @lezer/lr @lezer/highlight
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Building
|
||||
|
||||
npm i
|
||||
npm run build
|
||||
|
||||
### Testing
|
||||
|
||||
npm run test
|
||||
|
||||
## License
|
||||
|
||||
The code is licensed under an [Apache 2.0](https://github.com/prometheus/prometheus/blob/main/LICENSE) license.
|
Loading…
Reference in a new issue