Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update readme; gen md for config #14

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ gen

# generated interface mock files
*_moq.go

# test configs for debug launch configuration
.vscode/config
14 changes: 13 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
"--config",
"config.yaml"
]
},
{
"name": "Gen md docs",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"args": [
"gen-docs",
"--path",
"docs"
]
}
]
}
}
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @y-eight @NiklasTreml @puffitos @nico151999
* @y-eight @NiklasTreml @puffitos @nico151999 @lvlcn-t
76 changes: 56 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,80 @@
<h1 align="center">
`sparrow` aka Check Sparrow
</h1>
# `sparrow` aka Check Sparrow <!-- omit from toc -->

<p align="center">
<a href="https://github.com/caas-team/sparrow/actions/workflows/end2end.yaml" title="End2End Testing"><img src="https://github.com/caas-team/sparrow/actions/workflows/end2end.yaml/badge.svg"></a>
<a href="/../../commits/" title="Last Commit"><img src="https://img.shields.io/github/last-commit/caas-team/sparrow?style=flat"></a>
<a href="/../../issues" title="Open Issues"><img src="https://img.shields.io/github/issues/caas-team/sparrow?style=flat"></a>
<a href="./LICENSE" title="License"><img src="https://img.shields.io/badge/License-Apache%202.0-green.svg?style=flat"></a>
</p>

<p align="center">
<a href="#development">Development</a> •
<a href="#documentation">Documentation</a> •
<a href="#support-and-feedback">Support</a> •
<a href="#how-to-contribute">Contribute</a> •
<a href="#licensing">Licensing</a>
</p>
- [About this component](#about-this-component)
- [Installation](#installation)
- [Binary](#binary)
- [Container Image](#container-image)
- [Helm](#helm)
- [Usage](#usage)
- [Configuration](#configuration)
- [Startup](#startup)
- [Runtime](#runtime)
- [API](#api)
- [Code of Conduct](#code-of-conduct)
- [Working Language](#working-language)
- [Support and Feedback](#support-and-feedback)
- [How to Contribute](#how-to-contribute)
- [Licensing](#licensing)


The `sparrow` is an infrastructure monitoring tool. The binary includes several checks (e.g. health check) that will be executed periodically.

## About this component

The `sparrow` performs several checks to monitor the health of the infrastructure and network from its point of view. The following checks are available:

1. Health check - `health`: The `sparrow` is able perform an http-based (HTTP/1.1) health check to provided endpoints. The `sparrow` will expose its own health check endpoint as well.

2. Latency check - `rtt`: The `sparrow` is able to communicate with other `sparrow` instances to calculate the time a request takes to the target and back. The check is http (HTTP/1.1) based as well.

## Installation

The `sparrow` is provided as an small binary & a container image.

### Binary

tbd

## About this component
### Container Image

tbd

## Installation
### Helm

tbd

## Usage

Use `sparrow run` to execute the instance.

## Configuration

The configuration is divided into two parts. The startup configuration and the runtime configuration. The startup configuration is a technical configuration to configure the `sparrow` instance itself. The runtime configuration will be loaded by the `loader` from a remote endpoint. This configuration consist of the checks configuration.

### Startup

The available configuration options can found in the [CLI flag documentation](docs/sparrow.md).

The `sparrow` is able to get the startup configuration from different sources as follows.

Priority of configuration (high to low):

1. CLI flags
2. Environment variables
3. Defined configuration file
4. Default configuration file

Example runtime configuration:
### Runtime

Besides the technical startup configuration the configuration for the `sparrow` checks is loaded dynamically from an http endpoint. The `loader` is able to load the configuration dynamically during the runtime. Checks can be enabled, disabled and configured. The available loader confutation options for the startup configuration can be found in [here](sparrow_run.md)

Example format of a runtime configuration:

```YAML
apiVersion: 0.0.1
Expand All @@ -44,9 +84,9 @@ checks:
enabled: true
```

## Development
### API

tbd
The `sparrow` exposes an API that does provide access to the check results. Each check will register its own endpoint at `/v1/metrics/{check-name}`. The API definition will be exposed at `/openapi`

## Code of Conduct

Expand All @@ -61,10 +101,6 @@ We also ask all interested people to use English as the preferred language to cr
in their code (comments, documentation, etc.) and when you send requests to us.
The application itself and all end-user facing content will be made available in other languages as needed.

## Documentation

tbd

## Support and Feedback

The following channels are available for discussions, feedback, and support requests:
Expand Down
31 changes: 31 additions & 0 deletions cmd/gen-docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

//go:generate go run ../main.go gen-docs --path ../docs

import (
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

// NewCmdRun creates a new gen-docs command
func NewCmdGenDocs(rootCmd *cobra.Command) *cobra.Command {
var docPath string

cmd := &cobra.Command{
Use: "gen-docs",
Short: "Generate markdown documentation",
Long: `Generate the markdown documentation of available CLI flags`,
Run: runGenDocs(rootCmd, &docPath),
}

cmd.PersistentFlags().StringVar(&docPath, "path", "docs", "directory path where the markdown files will be created")

return cmd
}

// run is the entry point to start the sparrow
func runGenDocs(rootCmd *cobra.Command, path *string) func(cmd *cobra.Command, args []string) {
return func(cmd *cobra.Command, args []string) {
doc.GenMarkdownTree(rootCmd, *path)
}
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func NewCmdRoot(version string) *cobra.Command {
func Execute(version string) {
cmd := NewCmdRoot(version)
cmd.AddCommand(NewCmdRun())
cmd.AddCommand(NewCmdGenDocs(cmd))

if err := cmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down
23 changes: 23 additions & 0 deletions docs/sparrow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## sparrow

Sparrow, the infrastructure monitoring agent

### Synopsis

Sparrow is an infrastructure monitoring agent that is able to perform different checks.
The check results are exposed via an API.

### Options

```
--config string config file (default is $HOME/.sparrow.yaml)
-h, --help help for sparrow
```

### SEE ALSO

* [sparrow completion](sparrow_completion.md) - Generate the autocompletion script for the specified shell
* [sparrow gen-docs](sparrow_gen-docs.md) - Generate markdown documentation
* [sparrow run](sparrow_run.md) - Run sparrow

###### Auto generated by spf13/cobra on 23-Nov-2023
31 changes: 31 additions & 0 deletions docs/sparrow_completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## sparrow completion

Generate the autocompletion script for the specified shell

### Synopsis

Generate the autocompletion script for sparrow for the specified shell.
See each sub-command's help for details on how to use the generated script.


### Options

```
-h, --help help for completion
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.sparrow.yaml)
```

### SEE ALSO

* [sparrow](sparrow.md) - Sparrow, the infrastructure monitoring agent
* [sparrow completion bash](sparrow_completion_bash.md) - Generate the autocompletion script for bash
* [sparrow completion fish](sparrow_completion_fish.md) - Generate the autocompletion script for fish
* [sparrow completion powershell](sparrow_completion_powershell.md) - Generate the autocompletion script for powershell
* [sparrow completion zsh](sparrow_completion_zsh.md) - Generate the autocompletion script for zsh

###### Auto generated by spf13/cobra on 23-Nov-2023
50 changes: 50 additions & 0 deletions docs/sparrow_completion_bash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## sparrow completion bash

Generate the autocompletion script for bash

### Synopsis

Generate the autocompletion script for the bash shell.

This script depends on the 'bash-completion' package.
If it is not installed already, you can install it via your OS's package manager.

To load completions in your current shell session:

source <(sparrow completion bash)

To load completions for every new session, execute once:

#### Linux:

sparrow completion bash > /etc/bash_completion.d/sparrow

#### macOS:

sparrow completion bash > $(brew --prefix)/etc/bash_completion.d/sparrow

You will need to start a new shell for this setup to take effect.


```
sparrow completion bash
```

### Options

```
-h, --help help for bash
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.sparrow.yaml)
```

### SEE ALSO

* [sparrow completion](sparrow_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 23-Nov-2023
41 changes: 41 additions & 0 deletions docs/sparrow_completion_fish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## sparrow completion fish

Generate the autocompletion script for fish

### Synopsis

Generate the autocompletion script for the fish shell.

To load completions in your current shell session:

sparrow completion fish | source

To load completions for every new session, execute once:

sparrow completion fish > ~/.config/fish/completions/sparrow.fish

You will need to start a new shell for this setup to take effect.


```
sparrow completion fish [flags]
```

### Options

```
-h, --help help for fish
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.sparrow.yaml)
```

### SEE ALSO

* [sparrow completion](sparrow_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 23-Nov-2023
38 changes: 38 additions & 0 deletions docs/sparrow_completion_powershell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## sparrow completion powershell

Generate the autocompletion script for powershell

### Synopsis

Generate the autocompletion script for powershell.

To load completions in your current shell session:

sparrow completion powershell | Out-String | Invoke-Expression

To load completions for every new session, add the output of the above command
to your powershell profile.


```
sparrow completion powershell [flags]
```

### Options

```
-h, --help help for powershell
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.sparrow.yaml)
```

### SEE ALSO

* [sparrow completion](sparrow_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 23-Nov-2023
Loading