promql-langserver

module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: Apache-2.0, BSD-3-Clause

README

CircleCI Go Report Card GoDoc

Warning: This software is not in a particulary useful or stable state yet.

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 a 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 langauge 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.

Directories

Path Synopsis
cmd
nolint: lll
nolint: lll
cache
nolint:lll
nolint:lll
vendored
go-tools/fastwalk
Package fastwalk provides a faster version of filepath.Walk for file system scanning tools.
Package fastwalk provides a faster version of filepath.Walk for file system scanning tools.
go-tools/gopathwalk
Package gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT.
Package gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT.
go-tools/imports
Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
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.
go-tools/lsp
Package lsp implements LSP for gopls.
Package lsp implements LSP for gopls.
go-tools/lsp/browser
Package browser provides utilities for interacting with users' browsers.
Package browser provides utilities for interacting with users' browsers.
go-tools/lsp/cache
Package cache implements the caching layer for gopls.
Package cache implements the caching layer for gopls.
go-tools/lsp/cmd
Package cmd handles the gopls command line.
Package cmd handles the gopls command line.
go-tools/lsp/cmd/test
Package cmdtest contains the test suite for the command line behavior of gopls.
Package cmdtest contains the test suite for the command line behavior of gopls.
go-tools/lsp/debug
Package debug exports debug information for gopls.
Package debug exports debug information for gopls.
go-tools/lsp/diff
Package diff supports a pluggable diff algorithm.
Package diff supports a pluggable diff algorithm.
go-tools/lsp/diff/difftest
Package difftest supplies a set of tests that will operate on any implementation of a diff algorithm as exposed by "github.com/prometheus-community/promql-langserver/vendored/go-tools/lsp/diff"
Package difftest supplies a set of tests that will operate on any implementation of a diff algorithm as exposed by "github.com/prometheus-community/promql-langserver/vendored/go-tools/lsp/diff"
go-tools/lsp/diff/myers
Package myers implements the Myers diff algorithm.
Package myers implements the Myers diff algorithm.
go-tools/lsp/fuzzy
Package fuzzy implements a fuzzy matching algorithm.
Package fuzzy implements a fuzzy matching algorithm.
go-tools/lsp/helper
Invoke with //go:generate helper/helper -t Server -d protocol/tsserver.go -u lsp -o server_gen.go invoke in internal/lsp
Invoke with //go:generate helper/helper -t Server -d protocol/tsserver.go -u lsp -o server_gen.go invoke in internal/lsp
go-tools/lsp/mod
Package mod provides core features related to go.mod file handling for use by Go editors and tools.
Package mod provides core features related to go.mod file handling for use by Go editors and tools.
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".
go-tools/lsp/protocol/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".
go-tools/lsp/snippet
Package snippet implements the specification for the LSP snippet format.
Package snippet implements the specification for the LSP snippet format.
go-tools/lsp/source
Package source provides core features for use by Go editors and tools.
Package source provides core features for use by Go editors and tools.
go-tools/lsp/telemetry
Package telemetry provides the hooks and adapters to allow use of telemetry throughout gopls.
Package telemetry provides the hooks and adapters to allow use of telemetry throughout gopls.
go-tools/lsp/tests
Package tests exports functionality to be used across a variety of gopls tests.
Package tests exports functionality to be used across a variety of gopls tests.
go-tools/memoize
Package memoize supports memoizing the return values of functions with idempotent results that are expensive to compute.
Package memoize supports memoizing the return values of functions with idempotent results that are expensive to compute.
go-tools/module
Package module defines the module.Version type along with support code.
Package module defines the module.Version type along with support code.
go-tools/packagesinternal
Package packagesinternal exposes internal-only fields from go/packages.
Package packagesinternal exposes internal-only fields from go/packages.
go-tools/semver
Package semver implements comparison of semantic version strings.
Package semver implements comparison of semantic version strings.
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.
go-tools/telemetry
Package telemetry provides an opinionated set of packages that cover the main concepts of telemetry in an implementation agnostic way.
Package telemetry provides an opinionated set of packages that cover the main concepts of telemetry in an implementation agnostic way.
go-tools/telemetry/export
Package export holds the definition of the telemetry Exporter interface, along with some simple implementations.
Package export holds the definition of the telemetry Exporter interface, along with some simple implementations.
go-tools/telemetry/export/export
Package export holds the definition of the telemetry Exporter interface, along with some simple implementations.
Package export holds the definition of the telemetry Exporter interface, along with some simple implementations.
go-tools/telemetry/export/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.
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.
go-tools/telemetry/export/ocagent/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.
go-tools/telemetry/log
Package log is a context based logging package, designed to interact well with both the lsp protocol and the other telemetry packages.
Package log is a context based logging package, designed to interact well with both the lsp protocol and the other telemetry packages.
go-tools/telemetry/log/log
Package log is a context based logging package, designed to interact well with both the lsp protocol and the other telemetry packages.
Package log is a context based logging package, designed to interact well with both the lsp protocol and the other telemetry packages.
go-tools/telemetry/metric
Package metric aggregates stats into metrics that can be exported.
Package metric aggregates stats into metrics that can be exported.
go-tools/telemetry/metric/metric
Package metric aggregates stats into metrics that can be exported.
Package metric aggregates stats into metrics that can be exported.
go-tools/telemetry/stats
Package stats provides support for recording telemetry statistics.
Package stats provides support for recording telemetry statistics.
go-tools/telemetry/stats/stats
Package stats provides support for recording telemetry statistics.
Package stats provides support for recording telemetry statistics.
go-tools/telemetry/tag
Package tag provides support for telemetry tagging.
Package tag provides support for telemetry tagging.
go-tools/telemetry/tag/tag
Package tag provides support for telemetry tagging.
Package tag provides support for telemetry tagging.
go-tools/telemetry/trace
Package trace adds support for telemetry tracing.
Package trace adds support for telemetry tracing.
go-tools/telemetry/trace/trace
Package trace adds support for telemetry tracing.
Package trace adds support for telemetry tracing.
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.
go-tools/telemetry/unit/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.
go-tools/testenv
Package testenv contains helper functions for skipping tests based on which tools are present in the environment.
Package testenv contains helper functions for skipping tests based on which tools are present in the environment.
go-tools/tool
Package tool is an opinionated harness for writing Go tools.
Package tool is an opinionated harness for writing Go tools.
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.

Jump to

Keyboard shortcuts

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