promql-langserver

module
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2020 License: Apache-2.0, BSD-3-Clause

README

CircleCI Go Report Card GoDoc golangci-lint

promql-lsp

Implementation of the Language Server Protocol for PromQL.

Roadmap

  • Connect to IDEs and text editors over
    • Stdio
    • Websocket
    • HTTP
  • Sync document content with the client
  • Support plain PromQL queries
  • Support queries inside yaml files (e.g. alertmanager configuration)
  • Connect to a prometheus instance to get label and metric data
  • Show error messages for incorrect queries in the client
  • Show documentation on hover
    • Type information
    • Function documentation
    • Aggregator documentation
    • Keyword documentation
    • Metric and label help strings from a prometheus instance
  • Completion
    • Functions
    • Metrics
    • Recording Rules
    • Aggregators
    • Labels
    • Label Values
    • Context sensitive, i.e respecting function argument types
  • Signature information for functions (while typing)
  • (Linting)
  • (Formatting)

Some Screenshots

Completion in VS Code

Completion in VS Code

Metric metadata from a Prometheus Server

Metric Metadata in VS Code

Viewing documentation right from your editor

Docs in VS Code

Vim and other editors are supported, too

Vim

Using the Language Server

A Language Server on its own is not very useful. You need some Language Client to use it with.

The following Language Clients have been tested with this language server. More will be added in the future.

Feel free to reach out if you want to use it with another Editor/Tool.

VS Code

There exists a VS Code extension based on this language server: https://github.com/slrtbtfs/vscode-prometheus

It is used as the main test platform for this language server.

Since it isn't published on the Extensions Marketplace yet, you'll have to follow the somewhat more complicated installation steps described in the README there.

(Neo)Vim

With Vim, currently only PromQL queries inside YAML files work without additional support. Generally the experience with Vim is more buggy than with VS Code.

Setup
  1. Install the YouCompleteMe Plugin.

  2. Put the configuration following configuration file for the language server in .vim/promql-lsp.yaml.

     # Change this adress to the address of the prometheus server you want to use for metadata
     prometheus_url: http://localhost:9090
     rpc_trace: text
    
  3. Add the following to your .vimrc

     let g:ycm_language_server = [
       \   { 'name': 'promql',
       \     'filetypes': [ 'yaml' ],
       \     'cmdline': [ 'promql-langserver', '--config-file', expand('~/.vim/promql-lsp.yaml')]
       \   },
       \ ]
    
Debugging

The Vim command :YcmDebugInfo gives status information and points to logfiles.

Sublime Text 3
  1. Install package LSP, LSP-promql via Package Control.
  2. Follow the installation instruction.

Directories

Path Synopsis
cmd
internal
vendored/go-tools/jsonrpc2
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
vendored/go-tools/jsonrpc2/servertest
Package servertest provides utilities for running tests against a remote LSP server.
Package servertest provides utilities for running tests against a remote LSP server.
vendored/go-tools/lsp/debug/tag
Package tag provides the labels used for telemetry throughout gopls.
Package tag provides the labels used for telemetry throughout gopls.
vendored/go-tools/lsp/protocol
Package protocol contains the structs that map directly to the wire format of the "Language Server Protocol".
Package protocol contains the structs that map directly to the wire format of the "Language Server Protocol".
vendored/go-tools/span
Package span contains support for representing with positions and ranges in text files.
Package span contains support for representing with positions and ranges in text files.
vendored/go-tools/telemetry
Package telemetry provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way.
Package telemetry provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way.
vendored/go-tools/telemetry/event
Package event provides support for event based telemetry.
Package event provides support for event based telemetry.
vendored/go-tools/telemetry/export/metric
Package metric aggregates events into metrics that can be exported.
Package metric aggregates events into metrics that can be exported.
vendored/go-tools/telemetry/export/ocagent
Package ocagent adds the ability to export all telemetry to an ocagent.
Package ocagent adds the ability to export all telemetry to an ocagent.
vendored/go-tools/telemetry/unit
Package unit holds the definitions for the units you can use in telemetry.
Package unit holds the definitions for the units you can use in telemetry.
vendored/go-tools/xcontext
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
cache
Package cache is the component of the PromQL language server that is responsible for the caching the content and parse results of documents opened in the language client.
Package cache is the component of the PromQL language server that is responsible for the caching the content and parse results of documents opened in the language client.
Package rest provides a REST API to access the features of the PromQL language server with a stateless API.
Package rest provides a REST API to access the features of the PromQL language server with a stateless API.
Websocket provides support to run the language server over websocket (experimental).
Websocket provides support to run the language server over websocket (experimental).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL