opensearch-project / observability

Visualize and explore your logs, traces and metrics data in OpenSearch Dashboards
https://opensearch.org/docs/latest/observability-plugin/index/
Apache License 2.0
52 stars 98 forks source link

[FEATURE] Integration Templating CLI #1451

Open Swiddis opened 1 year ago

Swiddis commented 1 year ago

https://user-images.githubusercontent.com/31739405/233336538-7489b6db-3128-48a1-9dc9-75cc6b907b1e.mp4

Integrations CLI Design

Purpose

Provide the user a simple UI to work with integrations, including: creation, packaging, and publishing.

Background

Users don’t have access to a simple workflow to initialize, deploy, and publish Integrations. Maintaining integrations is hard, as it requires a configuration file and multiple directories with correctly set-up resources. To make the process easier for users, we will develop a CLI tool that enables:

The CLI is primarily meant for ease-of-use with regard to the integrations ecosystem. There are 3 use cases being targeted.

  1. A new Integrations user who wants to make an integration for their toolkit. They know roughly what they want, but not an exact dependency list or the components they need to supply.
  2. An experienced user who knows precisely what they want, and they want to be able to make it happen quickly and accurately.
  3. An integration developer, who will have an integration set up, but they want to quickly iterate on it and share it with confidence that it won't cause breakage for them or their users.

For now, the integrations CLI is a part of the Observability repository. When integrations are moved to their own repo, the CLI will move with it.

Requirements

Design Considerations

Consolidated Validation Logic

The project will have two components that need to work together. Consolidating the logic for the two components is important to avoid inconsistent results.

To facilitate consistent logic for each component, we need to settle on using a standard system for organizing that logic. After consideration, we've settled on:

In addition to JSON validation, there is more complicated version checking logic that we’ll have to write. How do we maintain consistency with this logic? Some options:

Commands

There has historically been a lot of disagreement on what the different verbs regarding this process mean. Please see the glossary at the end of this document. The exact usage of these verbs must be communicated to the users.

For processing CLI arguments, we will be using the click library, for consistency with existing OS CLI tools.

CLI Precise Description

Usage: integrations-cli [--version] [--help] <command> [<args>]
 integrations-cli create  Create a new Integration from a specified template
 integrations-cli check   Analyze the current Integration and report errors
 integrations-cli package Zip the current Integration so it can be uploaded to the Integration Plugin
Usage: integrations-cli create [--help] [--presets] <name> [<args>]
Create a new Integration from a specified template

Arguments:
  name               The name of the integration

Options:
  --help             Show this help page
  --presets          List available presets
  --preset <preset>  Generate using the provided preset
  --directory <dir>  Specify the directory in which to create the integration (default: './<name>')
Creating new integration '<name>'

Integration description (default: ''): 

License (default: 'Apache-2.0'):

Data Source Examples:
- kubernetes
- nginx
- otel-collector
Select a Data Source:  

Data Source Version: (default: 'latest'): 

Schema Version Options:
- 0.1
- 0.2
- 1.0
- latest
Schema Version (default: 'latest'): 

Integration labels (comma-separated list, default: none): 

Catalog for the Integration (default: 'observability'): 

Would you like to add collections interactively? (y/n):
Usage: integrations-cli check [--help] [<dir>] [<args>]
Analyze the current Integration and report errors

Arguments:
  dir     The directory of the integration to check (default: .)

Options:
  --help  Show this help page
Usage: integrations-cli package [--help] [<dir>] [<args>]
Zip the current Integration so it can be uploaded to the Integration Plugin

Arguments:
  dir     The directory of the integration to package (default: .)

Options:
  --help          Show this help page

Tests

A difficult part of testing will be ensuring that the front-end validator does not certify an integration that the API will reject. Using a stable JSON Schema library for the task will be critical, but there should also be integration tests that check the CLI upload against a running cluster with Observability.

To ensure validation is functioning as intended, we should find and include a fuzzing framework, such as JSON Schema to Elm.

New endpoints will need Pen Testing.

Implementation Plan

Short-Term Deliverable

Goals for 2.7

Goals for 2.8+

Glossary

Build (= Package): Packaging a folder containing an integration into a zip file. The zip should be able to be deployed to the cluster as-is. Check (= Validate): Ensuring that the integration is correct and will be accepted by the server. Deploy (= Import): Moving a built integration from a local filesystem to a remote cluster. After this step, all references to the integration should be via a cluster index. Install: Putting an integration in a local filesystem that will be loaded.

anirudha commented 1 year ago

https://user-images.githubusercontent.com/19362/233165982-10abba35-675b-4689-a775-93d7b1050bbc.mov

https://user-images.githubusercontent.com/19362/233166018-64e74811-64f2-4765-a8fd-983f8a92c3ae.mov