Code Monkey home page Code Monkey logo

vscode-logstash-editor's Introduction

VSCode Logstash Editor

Visual Studio Code extension that provides completion, documentation and auto-formatting for Logstash pipeline configuration files, logstash.yml, pipelines.yml, filebeat.yml and Elasticsearch index template json files.

Example

Features

  • Provides completion for Logstash pipeline configuration files (sections, plugins, options), depending current cursor position.
    For example, if cursor is inside grok filter, options for grok filter are suggested.
  • All completion data is generated from official Logstash documentation
  • Options for a plugin are sorted : first required options, then optional specific options, and finally optional common options
  • When you preselect an item, a link to official documentation, a short description and an example (if available) are provided
  • If you choose a completion item, a code snippet is automatically inserted with relevant content:
    • for a plugin, inserted snippet is the plugin block and all its required options
    • for an option, inserted snippet is based on option type (string, boolean, number, string_duration, array, hash) and option default value
  • Provides completion for if statement
  • Provides documentation when hover on a section, a plugin or an option
  • Provides document formatting and document range formatting on a Logstash pipeline configuration file
  • Provides completion for "logstash.yml" and "pipelines.yml" files
  • Provides completion for Filebeat configuration files:
    • filebeat.yml
    • filebeat.config.inputs.yml
    • filebeat.config.modules.yml
    • filebeat*/inputs.d/*.yml
    • filebeat*/modules.d/*.yml
  • Provides completion for Elasticsearch index template (and composable index template) json files, based on a json schema
  • Provides a specific index template json schema for Elasticsearch 6.x and 7.x
  • Provides "logstash.version" configuration setting to choose Logstash version (for completion)
  • Provides "Set Logstash Version" command (shortcut: Ctrl+Shift+L) to change Logstash version setting
  • Supported Logstash versions: 6.8, 7.2, 7.5, 7.9, 7.12, 7.17
  • Following file patterns are automatically associated to Logstash language:
    • *logstash.conf
    • *logstash.conf.j2
    • *logstash.conf.template
    • logstash-*.conf
  • Following file patterns are automatically associated to Elasticsearch index template json schema:
    • *elasticsearch-template.json
    • *elasticsearch-template-es7x.json
    • *elasticsearch-template-es6x.json

Syntax highlighting

This extension does not provide syntax highlighting for Logstash configuration files, because this feature is already provdided by Logstash Configuration Syntax / Language Support extension.
Both extensions complement each other perfectly.

Troubleshooting

  • if completion does not work and your Visual Studio Code version is less than 1.52, upgrade your Visual Studio Code version.
  • if you don't see documentation associated to completion suggestions, type "Ctrl + Space" once again or click on the ">" (or "i") button: Example

Advanced tip: choose Elasticsearch index template minor version

By default, with Logstash Editor extension, Elasticsearch index template version is based on file name. And only major versions are supported (6 and 7).

If you want to have completion for one specific minor version, you can do it with 2 ways:

  • you use "$schema" attribute in index template JSON file:
{
  "$schema": "https://raw.githubusercontent.com/fbaligand/vscode-logstash-editor/es-<VERSION>/jsonschemas/elasticsearch-template-es7x.schema.json"
}
  • in Visual Studio Code settings, you associate you index template file pattern with URL to JSON schema:
"json.schemas": [
    {
        "fileMatch": [
            "/my-elasticsearch-index-template.json"
        ],
        "url": "https://raw.githubusercontent.com/fbaligand/vscode-logstash-editor/es-<VERSION>/jsonschemas/elasticsearch-template-es7x.schema.json"
    }
]

In both cases, you replace <VERSION> with one of the supported versions: 7.2, 7.5, 7.9, 7.12 or 7.17

Limitations

For now, only this format style is supported for completion in Logstash configuration files:

filter {
	tcp {
		port => 12345
	}
}

This format style is not supported:

filter 
{
	tcp 
	{
		port => 12345
	}
}

Neither this one:

filter { tcp { port => 12345 } }

vscode-logstash-editor's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vscode-logstash-editor's Issues

syntax highlighting

hi there, nice extension!

I just discovered this because I was thinking that it may be a good idea and I thought on searching it :)

I was wondering if you are willing to support syntax highlighting. The default .conf syntax highlighting went off after loading the extension. Are you thinking on supporting the default syntax highlighting for .conf files?

nice work.

logstash-editor extension is not found in the Visual Studio Extentions

image

Microsoft Visual Studio Community 2019
Version 16.11.26
VisualStudio.16.Release/16.11.26+33529.622
Microsoft .NET Framework
Version 4.8.04084
Installed Version: Community
ASP.NET and Web Tools 2019 16.11.115.10959
ASP.NET and Web Tools 2019
Azure App Service Tools v3.0.0 16.11.115.10959
Azure App Service Tools v3.0.0

Colorized code?

When I use this addon in visual studio code 1.50.1 I lose all colorized code. Is this working as intended with your extension?

my config:

output {
        elasticsearch {
                hosts => [ "127.0.0.1:9200" ]
		index => "logstash-%{+YYYY.MM.dd}"
        }
}

And this is what it looks like when vscode autodetects it as "properties"
image

Filebeat / Elasticsearch template language mode

For Logstash config files, when the file name doesn't match the expected naming scheme. The work around is to trigger the "Change Language Mode" action and then select "Logstash". This is great.

For Filebeat/Elasticsearch, there is no "Filebeat YAML" or "Elasticsearch JSON Template" language mode. So if the file name doesn't match the expected naming scheme you're stuck.

incorrect formatting on some specific patterns

Hi,

formatting overall works well, but sometimes breaks.. I am not able to find the reason for now, but here's an example :

 grok {
    patterns_dir => ["/usr/share/logstash/config/patterns/"]
    match => { "message" => "%{IP:[source][ip]} - - \[%{LOG_TIMESTAMP:timestamp}] \"%{WORD:method} %{RESOURCE:[url][path]}%{QUESTIONMARK_OR_NOT}%{QUERY_PARAMS:[url][query]} HTTP/%{NUMBER:[http][version]}\" %{NUMBER:[http][response][status_code]} %{NUMBER:[http][response][bytes]}" }
}

becomes after formatting :

grok {
    patterns_dir => ["/usr/share/logstash/config/patterns/"]
    match => {
        "message" => "%{IP:[source][ip]} - - \[%{LOG_TIMESTAMP:timestamp}] \"% {
            WORD:method
                        }
% {
                RESOURCE:[url][path]
                    }
% {
                    QUESTIONMARK_OR_NOT
                }
% {
                        QUERY_PARAMS:[url][query]
            }
HTTP/% {
                            NUMBER:[http][version]
        }
\" %{NUMBER:[http][response][status_code]} %{NUMBER:[http][response][bytes]}"
    }
}

is there anything I should do in my config to avoid this ?

I am using v0.4.0 in VSC 1.53.2

Additional Logstash Conf Files

Hi,
When I used this extension for logstash.yml and pipeline.yml, it was great! However; the system I inherited and don't want to refactor uses a parameter in the pipeline.yml that points to /etc/logstash/conf.d/** for additional configuration files. Each of these is prefixed with a number and suffixed with ".conf". According to the Logstash documentation they are read in numeric order and then earlier config wins if there is a duplicate.
However; I can't figure out how to use your extension to "work" these files as they don't have one of the fixed names.
I would like to either point to the pipeline.yml and say those are good, or allow me to specify that some arbitrary directory (of my choosing) will contain some Logstash ".conf" files.
Thanks,
Tom

Add an option to enable vscode basic word suggestion

The extension is working great but once is activated, it breaks normal word suggestions. I mean, not code snipped or logstash keyword but document known word suggestions.

If I get back from "Logstash" to "Plain text" language mode (bottom-right corner) normal suggestions are back but of course I loose all the extension features.

VSCode: v1.77.3
Extension: v1.2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.