Skip to content

Commit

Permalink
docs: remove utils from online docs, improve READMEs (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreDemailly authored Jul 9, 2024
1 parent 7ebb58d commit 4054b08
Show file tree
Hide file tree
Showing 29 changed files with 604 additions and 856 deletions.
275 changes: 57 additions & 218 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,233 +6,72 @@ export default defineConfig({
description: "Grafana Loki Alerting Agent",
themeConfig: {
nav: [
{ text: 'Agent', link: '/agent/installation', activeMatch: '^/agent/' },
{ text: 'Config', link: '/config/index', activeMatch: '^/config/' },
{
text: "Utils",
items: [
{ text: 'Logql', link: '/logql/installation', activeMatch: '^/logql/' },
{ text: 'Morphix', link: '/morphix/installation', activeMatch: '^/morphix/' },
{ text: 'Pattern', link: '/pattern/installation', activeMatch: '^/pattern/' },
]
},
{ text: 'Documentation', link: '/agent/installation', activeMatch: '^/documentation/' },
{
text: "Notifiers",
items: [
{ text: 'Notifiers', link: '/notifiers/installation', activeMatch: '^/notifiers/' },
{ text: 'Discord', link: '/discord/installation', activeMatch: '^/discord/' },
{ text: 'Slack', link: '/slack/installation', activeMatch: '^/slack/' },
{ text: 'Teams', link: '/teams/installation', activeMatch: '^/teams/' },
{ text: 'Notifiers', link: '/notifiers/README', activeMatch: '^/notifiers/' },
{ text: 'Discord', link: '/discord/README', activeMatch: '^/discord/' },
{ text: 'Slack', link: '/slack/README', activeMatch: '^/slack/' },
{ text: 'Teams', link: '/teams/README', activeMatch: '^/teams/' },
]
}
],
search: {
provider: 'local',
},
sidebar: {
"/agent": [
{
text: "Agent",
items: [
{
text: "Installation",
link: "/agent/installation"
},
{
text: "Getting Started",
link: "/agent/getting-started"
},
{
text: "API",
link: "/agent/api"
},
{
text: "Advanced tips",
items: [
{ text: "Testing", link: "/agent/testing" }
]
}
]
}
],
"/config": [
{
text: "Config",
items: [
{
text: "Overview",
link: "/config/",
},
{
text: "Rules",
link: "/config/rules"
},
{
text: "Templates",
link: "/config/templates"
},
{
text: "Composite Rules",
link: "/config/composite-rules"
},
{
text: "Self Monitoring",
link: "/config/self-monitoring"
},
{
text: "Templates",
link: "/config/templates"
},
{
text: "Throttle",
link: "/config/throttle"
},
]
},
{
text: "API",
link: "/config/api"
},
{
text: "Interfaces",
link: "/config/interfaces"
},
{
text: "Advanced",
items: [
{
text: "JSON Schema",
link: "/config/json-schema"
}
]
}
],
"/logql": [
{
text: "Logql",
items: [
{
text: "Installation",
link: "/logql/installation"
},
{
text: "Usage",
link: "/logql/usage"
},
{
text: "API",
items: [
{
text: "Logql",
link: "/logql/LogQL"
},
{
text: "Stream Selector",
link: "/logql/StreamSelector"
},
{
text: "Line Filters",
link: "/logql/LineFilters"
},
{
text: "Label Filters",
link: "/logql/LabelFilters"
},
{
text: "Parser Expression",
link: "/logql/ParserExpression"
}
]
}
]
}
],
"/morphix": [
{
text: "Installation",
link: "/morphix/installation"
},
{
text: "Usage",
link: "/morphix/usage"
},
{
text: "API",
link: "/morphix/api"
},
{
text: "Functions",
link: "/morphix/functions"
},
],
"/pattern": [
{
text: "Installation",
link: "/pattern/installation"
},
{
text: "Usage",
link: "/pattern/usage"
},
{
text: "API",
items: [
{
text: "Pattern",
link: "/pattern/Pattern"
},
{
text: "NoopPattern",
link: "/pattern/NoopPattern"
},
{
text: "Shape",
link: "/pattern/shape"
}
]
},
],
"/discord": [
{
text: "Installation",
link: "/discord/installation"
},
{
text: "Usage",
link: "/discord/usage"
}
],
"/slack": [
{
text: "Installation",
link: "/slack/installation"
},
{
text: "Usage",
link: "/slack/usage"
}
],
"/teams": [
{
text: "Installation",
link: "/teams/installation"
},
{
text: "Usage",
link: "/teams/usage"
}
],
"/notifiers": [
{
text: "Installation",
link: "/notifiers/installation"
},
{
text: "Usage",
link: "/notifiers/usage"
}
]
},
sidebar: [
{
items: [
{
text: "Agent",
items: [
{
text: "Installation",
link: "/agent/installation"
},
{
text: "Getting Started",
link: "/agent/getting-started"
}
]
},
{
text: "Config",
items: [
{
text: "Overview",
link: "/config/",
},
{
text: "Rules",
link: "/config/rules"
},
{
text: "Templates",
link: "/config/templates"
},
{
text: "Composite Rules",
link: "/config/composite-rules"
},
{
text: "Self Monitoring",
link: "/config/self-monitoring"
},
{
text: "Templates",
link: "/config/templates"
},
{
text: "Throttle",
link: "/config/throttle"
},
]
}
]
}
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/MyUnisoft/sigyn/' }
]
Expand Down
73 changes: 72 additions & 1 deletion src/agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,79 @@
<img src="https://img.shields.io/github/license/MyUnisoft/sigyn?style=for-the-badge" alt="license">
</a>
</p>
## 🚧 Requirements

## Please see the [documentation here](https://myunisoft.github.io/sigyn/agent/installation.html).
- [Node.js](https://nodejs.org/en/) version 18 or higher

## πŸš€ Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://doc.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com)

```bash
$ npm i @sigyn/agent
# or
$ yarn add @sigyn/agent
```

### Add environment variables

```bash
$ touch .env
```

Add these variables:

```Dotenv
# Required
GRAFANA_API_TOKEN=your_token
# Default to sigyn.sqlite3
SIGYN_DB=your_db
```

### Add Sigyn config

```bash
$ touch sigyn.config.json
```

Please see [here](../config/docs/index.md#example-configuration) for config documentation

## πŸ“š Usage

```ts
import { start } from "@sigyn/agent";

await start();
```

## 🌐 API

### `start(location?: string, options?: StartOptions): Promise<ToadScheduler>`

Run Sigyn agent. It will fetch logs depending your rules `polling` and send alerts when `count` threshold is reached.

- `location: string` Optional, default to `process.cwd()`. The path to your SQLite database, it will create the file if it doesn't exists but the directory **must** exists.
- `options.logger: Logger` Optional, default to `pino`. You can use your own logger which must be an object with theses 3 methods: `debug`, `info` & `error`.
- `options.level` Optional, only works if no logger given. Set log level: `"info" | "debug" | "error"`.
- `options.timeout` Optional, you can provide a timeout for Grafana API requests. Default: `30_000`.

The returned scheduler instance allow you to put some extra logic if needed, see [API for scheduler](https://github.com/kibertoad/toad-scheduler/blob/main/README.md#api-for-scheduler).

## πŸ–‹οΈ Interfaces

```ts
interface Logger {
info: (message: string) => void;
error: (message: string) => void;
debug: (message: string) => void;
}

interface StartOptions {
logger?: Logger;
level?: "info" | "debug" | "error";
timeout?: number;
}
```

## License
MIT
Loading

0 comments on commit 4054b08

Please sign in to comment.