From 6c3c65f5295a773661cdea5fc353a0472e04f67c Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Tue, 13 Sep 2022 08:36:48 +0800 Subject: [PATCH] feat: Add a command to generate JSON Schema (#213) * add json schema generator * go fmt * remove the comma in the description * escape the comma * more fix * documatation * fix the title error * fix the format enum error * add the jsonschema issue in comment * Apply suggestions from code review Co-authored-by: Pantelis Roditis * Update docs/Manual.md Co-authored-by: Pantelis Roditis Co-authored-by: Pantelis Roditis Co-authored-by: Kun Zhao --- README.md | 2 + cmd/easeprobe/main.go | 10 + conf/conf.go | 101 +- conf/conf_test.go | 15 + conf/log.go | 20 +- docs/Manual.md | 27 +- eval/eval.go | 20 +- global/global.go | 12 +- go.mod | 2 + go.sum | 5 + notify/aws/conf.go | 12 +- notify/aws/sns.go | 18 +- notify/aws/sns_test.go | 2 +- notify/base/base.go | 16 +- notify/dingtalk/dingtalk.go | 4 +- notify/discord/discord.go | 8 +- notify/email/email.go | 10 +- notify/lark/lark.go | 2 +- notify/log/log.go | 10 +- notify/notify.go | 24 +- notify/shell/shell.go | 8 +- notify/slack/slack.go | 2 +- notify/sms/conf/conf.go | 14 +- notify/sms/sms.go | 2 +- notify/teams/teams.go | 2 +- notify/telegram/telegram.go | 4 +- notify/wecom/wecom.go | 2 +- probe/base/base.go | 18 +- probe/client/client.go | 2 +- probe/client/conf/conf.go | 10 +- probe/client/kafka/kafka.go | 4 +- probe/client/memcache/memcache.go | 2 +- probe/client/mongo/mongo.go | 6 +- probe/client/mysql/mysql.go | 4 +- probe/client/postgres/postgres.go | 2 +- probe/client/redis/redis.go | 4 +- probe/client/zookeeper/zookeeper.go | 4 +- probe/common.go | 10 +- probe/host/host.go | 16 +- probe/http/http.go | 30 +- probe/shell/shell.go | 14 +- probe/ssh/endpoint.go | 12 +- probe/ssh/ssh.go | 20 +- probe/tcp/tcp.go | 4 +- probe/tls/tls.go | 16 +- resources/schema.json | 1990 +++++++++++++++++++++++++++ 46 files changed, 2302 insertions(+), 220 deletions(-) create mode 100644 resources/schema.json diff --git a/README.md b/README.md index 0b5b97eb..6edc070e 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,8 @@ settings: interval: 1m # probe every minute for all probes ``` +You can check the [EaseProbe JSON Schema](./docs/Manual.md#81-easeprobe-json-schema) section to use a JSON Scheme file to make your life easier when you edit the configuration file. + ## 2.3 Run You can run the following command to start EaseProbe once built diff --git a/cmd/easeprobe/main.go b/cmd/easeprobe/main.go index a63c7294..736b390b 100644 --- a/cmd/easeprobe/main.go +++ b/cmd/easeprobe/main.go @@ -76,6 +76,7 @@ func main() { dryNotify := flag.Bool("d", os.Getenv("PROBE_DRY") == "true", "dry notification mode") yamlFile := flag.String("f", getEnvOrDefault("PROBE_CONFIG", "config.yaml"), "configuration file") + jsonSchema := flag.Bool("j", false, "show JSON schema") version := flag.Bool("v", false, "prints version") flag.Parse() @@ -84,6 +85,15 @@ func main() { os.Exit(0) } + if *jsonSchema { + schema, err := conf.JSONSchema() + if err != nil { + log.Fatalf("failed to show JSON schema: %v", err) + } + fmt.Println(schema) + os.Exit(0) + } + c, err := conf.New(yamlFile) if err != nil { log.Errorln("Fatal: Cannot read the YAML configuration file!") diff --git a/conf/conf.go b/conf/conf.go index 0976274d..1aacc46c 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -19,6 +19,7 @@ package conf import ( + "encoding/json" "io/ioutil" httpClient "net/http" netUrl "net/url" @@ -41,6 +42,7 @@ import ( "github.com/megaease/easeprobe/probe/tcp" "github.com/megaease/easeprobe/probe/tls" + "github.com/invopop/jsonschema" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v3" ) @@ -86,60 +88,91 @@ func (s *Schedule) UnmarshalYAML(unmarshal func(interface{}) error) error { // Notify is the settings of notification type Notify struct { - Retry global.Retry `yaml:"retry"` - Dry bool `yaml:"dry"` + Retry global.Retry `yaml:"retry" json:"retry,omitempty" jsonschema:"title=retry,description=the retry settings"` + Dry bool `yaml:"dry" json:"dry,omitempty" jsonschema:"title=dry,description=set true to make the notification dry run and will not be sent the message,default=false"` } // Probe is the settings of prober type Probe struct { - Interval time.Duration `yaml:"interval"` - Timeout time.Duration `yaml:"timeout"` + Interval time.Duration `yaml:"interval" json:"interval,omitempty" jsonschema:"type=string,format=duration,title=Probe Interval,description=the interval of probe,default=1m"` + Timeout time.Duration `yaml:"timeout" json:"timeout,omitempty" jsonschema:"type=string,format=duration,title=Probe Timeout,description=the timeout of probe,default=30s"` } // SLAReport is the settings for SLA report type SLAReport struct { - Schedule Schedule `yaml:"schedule"` - Time string `yaml:"time"` - Debug bool `yaml:"debug"` - DataFile string `yaml:"data"` - Backups int `yaml:"backups"` - Channels []string `yaml:"channels"` + Schedule Schedule `yaml:"schedule" json:"schedule" jsonschema:"type=string,enum=none,enum=hourly,enum=daily,enum=weekly,enum=monthly,title=Schedule,description=the schedule of SLA report"` + Time string `yaml:"time" json:"time,omitempty" jsonschema:"format=time,title=Time,description=the time of SLA report need to send out,example=23:59:59+08:00"` + Debug bool `yaml:"debug" json:"debug,omitempty" jsonschema:"title=Debug,description=if true the SLA report will be printed to stdout,default=false"` + DataFile string `yaml:"data" json:"data,omitempty" jsonschema:"title=Data File,description=the data file of SLA report, absolute path"` + Backups int `yaml:"backups" json:"backups,omitempty" jsonschema:"title=Backups,description=the number of backups of SLA report,default=5"` + Channels []string `yaml:"channels" json:"channels,omitempty" jsonschema:"title=Channels,description=the channels of SLA report"` } // HTTPServer is the settings of http server type HTTPServer struct { - IP string `yaml:"ip"` - Port string `yaml:"port"` - AutoRefreshTime time.Duration `yaml:"refresh"` - AccessLog Log `yaml:"log"` + IP string `yaml:"ip" json:"ip" jsonschema:"title=Web Server IP,description=the local ip address of the http server need to listen on,example=0.0.0.0"` + Port string `yaml:"port" json:"port" jsonschema:"type=integer,title=Web Server Port,description=port of the http server,default=8181"` + AutoRefreshTime time.Duration `yaml:"refresh" json:"refresh,omitempty" jsonschema:"type=string,title=Auto Refresh Time,description=auto refresh time of the http server,example=5s"` + AccessLog Log `yaml:"log" json:"log,omitempty" jsonschema:"title=Access Log,description=access log of the http server"` } // Settings is the EaseProbe configuration type Settings struct { - Name string `yaml:"name"` - IconURL string `yaml:"icon"` - PIDFile string `yaml:"pid"` - Log Log `yaml:"log"` - TimeFormat string `yaml:"timeformat"` - TimeZone string `yaml:"timezone"` - Probe Probe `yaml:"probe"` - Notify Notify `yaml:"notify"` - SLAReport SLAReport `yaml:"sla"` - HTTPServer HTTPServer `yaml:"http"` + Name string `yaml:"name" json:"name,omitempty" jsonschema:"title=EaseProbe Name,description=The name of the EaseProbe instance,default=EaseProbe"` + IconURL string `yaml:"icon" json:"icon,omitempty" jsonschema:"title=Icon URL,description=The URL of the icon of the EaseProbe instance"` + PIDFile string `yaml:"pid" json:"pid,omitempty" jsonschema:"title=PID File,description=The PID file of the EaseProbe instance ('-' means no PID file)"` + Log Log `yaml:"log" json:"log,omitempty" jsonschema:"title=EaseProbe Log,description=The log settings of the EaseProbe instance"` + TimeFormat string `yaml:"timeformat" json:"timeformat,omitempty" jsonschema:"title=Time Format,description=The time format of the EaseProbe instance,default=2006-01-02 15:04:05Z07:00"` + TimeZone string `yaml:"timezone" json:"timezone,omitempty" jsonschema:"title=Time Zone,description=The time zone of the EaseProbe instance,example=Asia/Shanghai,example=Europe/Berlin,default=UTC"` + Probe Probe `yaml:"probe" json:"probe,omitempty" jsonschema:"title=Probe Settings,description=The global probe settings of the EaseProbe instance"` + Notify Notify `yaml:"notify" json:"notify,omitempty" jsonschema:"title=Notify Settings,description=The global notify settings of the EaseProbe instance"` + SLAReport SLAReport `yaml:"sla" json:"sla,omitempty" jsonschema:"title=SLA Report Settings,description=The SLA report settings of the EaseProbe instance"` + HTTPServer HTTPServer `yaml:"http" json:"http,omitempty" jsonschema:"title=HTTP Server Settings,description=The HTTP server settings of the EaseProbe instance"` } // Conf is Probe configuration type Conf struct { - Version string `yaml:"version"` - HTTP []http.HTTP `yaml:"http"` - TCP []tcp.TCP `yaml:"tcp"` - Shell []shell.Shell `yaml:"shell"` - Client []client.Client `yaml:"client"` - SSH ssh.SSH `yaml:"ssh"` - TLS []tls.TLS `yaml:"tls"` - Host host.Host `yaml:"host"` - Notify notify.Config `yaml:"notify"` - Settings Settings `yaml:"settings"` + Version string `yaml:"version" json:"version,omitempty" jsonschema:"title=Version,description=Version of the EaseProbe configuration"` + HTTP []http.HTTP `yaml:"http" json:"http,omitempty" jsonschema:"title=HTTP Probe,description=HTTP Probe Configuration"` + TCP []tcp.TCP `yaml:"tcp" json:"tcp,omitempty" jsonschema:"title=TCP Probe,description=TCP Probe Configuration"` + Shell []shell.Shell `yaml:"shell" json:"shell,omitempty" jsonschema:"title=Shell Probe,description=Shell Probe Configuration"` + Client []client.Client `yaml:"client" json:"client,omitempty" jsonschema:"title=Native Client Probe,description=Native Client Probe Configuration"` + SSH ssh.SSH `yaml:"ssh" json:"ssh,omitempty" jsonschema:"title=SSH Probe,description=SSH Probe Configuration"` + TLS []tls.TLS `yaml:"tls" json:"tls,omitempty" jsonschema:"title=TLS Probe,description=TLS Probe Configuration"` + Host host.Host `yaml:"host" json:"host,omitempty" jsonschema:"title=Host Probe,description=Host Probe Configuration"` + Notify notify.Config `yaml:"notify" json:"notify,omitempty" jsonschema:"title=Notification,description=Notification Configuration"` + Settings Settings `yaml:"settings" json:"settings,omitempty" jsonschema:"title=Global Settings,description=EaseProbe Global configuration"` +} + +// JSONSchema return the json schema of the configuration +func JSONSchema() (string, error) { + r := new(jsonschema.Reflector) + + // The Struct name could be same, but the package name is different + // For example, all of the notification plugins have the same struct name - `NotifyConfig` + // This would cause the json schema to be wrong `$ref` to the same name. + // the following code is to fix this issue by adding the package name to the struct name + // p.s. this issue has been reported in: https://github.com/invopop/jsonschema/issues/42 + r.Namer = func(t reflect.Type) string { + name := t.Name() + if t.Kind() == reflect.Struct { + v := reflect.New(t) + vt := v.Elem().Type() + name = vt.PkgPath() + "/" + vt.Name() + name = strings.TrimPrefix(name, "github.com/megaease/easeprobe/") + name = strings.ReplaceAll(name, "/", "_") + log.Debugf("The struct name has been replaced [%s ==> %s]", t.Name(), name) + } + return name + } + + schema := r.Reflect(&Conf{}) + + resBytes, err := json.MarshalIndent(schema, "", " ") + if err != nil { + return "", err + } + return string(resBytes), nil } // Check if string is a url diff --git a/conf/conf_test.go b/conf/conf_test.go index 81b1d3af..c83679d1 100644 --- a/conf/conf_test.go +++ b/conf/conf_test.go @@ -18,6 +18,7 @@ package conf import ( + "encoding/json" "errors" "fmt" "io" @@ -735,3 +736,17 @@ func TestEmptyProbes(t *testing.T) { os.RemoveAll(file) os.RemoveAll("data") } + +func TestJSONSchema(t *testing.T) { + schema, err := JSONSchema() + assert.Nil(t, err) + assert.NotEmpty(t, schema) + + monkey.Patch(json.MarshalIndent, func(v interface{}, prefix, indent string) ([]byte, error) { + return nil, fmt.Errorf("error") + }) + schema, err = JSONSchema() + assert.NotNil(t, err) + assert.Empty(t, schema) + monkey.UnpatchAll() +} diff --git a/conf/log.go b/conf/log.go index c3759580..924c2657 100644 --- a/conf/log.go +++ b/conf/log.go @@ -58,16 +58,16 @@ func (l *LogLevel) GetLevel() log.Level { // Log is the log settings type Log struct { - Level LogLevel `yaml:"level"` - File string `yaml:"file"` - SelfRotate bool `yaml:"self_rotate"` - MaxSize int `yaml:"size"` - MaxAge int `yaml:"age"` - MaxBackups int `yaml:"backups"` - Compress bool `yaml:"compress"` - Writer io.Writer `yaml:"-"` - Logger *log.Logger `yaml:"-"` - IsStdout bool `yaml:"-"` + Level LogLevel `yaml:"level" json:"level,omitempty" jsonschema:"type=string,enum=debug,enum=info,enum=warn,enum=error,enum=fatal,enum=panic,title=Log Level,description=Log Level"` + File string `yaml:"file" json:"file,omitempty" jsonschema:"title=Log File,description=the file to save the log"` + SelfRotate bool `yaml:"self_rotate" json:"self_rotate,omitempty" jsonschema:"title=Self Rotate,description=whether to rotate the log file by self"` + MaxSize int `yaml:"size" json:"size,omitempty" jsonschema:"title=Max Size,description=the max size of the log file. the log file will be rotated if the size is larger than this value"` + MaxAge int `yaml:"age" json:"age,omitempty" jsonschema:"title=Max Age,description=the max age of the log file. the log file will be rotated if the age is larger than this value"` + MaxBackups int `yaml:"backups" json:"backups,omitempty" jsonschema:"title=Max Backups,description=the max backups of the log file. the rotated log file will be deleted if the backups is larger than this value"` + Compress bool `yaml:"compress" json:"compress,omitempty" jsonschema:"title=Compress,description=whether to compress the rotated log file"` + Writer io.Writer `yaml:"-" json:"-"` + Logger *log.Logger `yaml:"-" json:"-"` + IsStdout bool `yaml:"-" json:"-"` } // NewLog create a new Log diff --git a/docs/Manual.md b/docs/Manual.md index b94625c9..f5ff2547 100644 --- a/docs/Manual.md +++ b/docs/Manual.md @@ -46,6 +46,8 @@ EaseProbe is a simple, standalone, and lightweight tool that can do health/statu - [7.7 Native Client Probe Configuration](#77-native-client-probe-configuration) - [7.8 Notification Configuration](#78-notification-configuration) - [7.9 Global Setting Configuration](#79-global-setting-configuration) +- [8. Tools](#8-tools) + - [8.1 EaseProbe JSON Schema](#81-easeprobe-json-schema) @@ -1329,4 +1331,27 @@ settings: # check the following link to see the time zone list # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones timezone: "America/New_York" # default: UTC -``` \ No newline at end of file +``` +# 8. Tools + +## 8.1 EaseProbe JSON Schema + +We have a JSON schema that can be used to validate your EaseProbe configuration. The schema can be found at [resources/schema.json](https://raw.githubusercontent.com/megaease/easeprobe/main/resources/schema.json). + +The schema file can be generated at any time by running the following command: + +```bash +$ easeprobe -j > schema.json +``` + +In order to use the schema with VSCode for validating your configuration, you need to install the [YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) and add the following configuration to your `settings.json` file: + +```json +{ + "yaml.schemas": { + "https://raw.githubusercontent.com/megaease/easeprobe/main/resources/schema.json": [ + "/path/to/config.yaml" + ] + } +} +``` diff --git a/eval/eval.go b/eval/eval.go index fc2149a3..57658c0e 100644 --- a/eval/eval.go +++ b/eval/eval.go @@ -28,10 +28,10 @@ import ( // Variable is the variable type type Variable struct { - Name string `yaml:"name"` - Type VarType `yaml:"type"` - Query string `yaml:"query"` - Value interface{} + Name string `yaml:"name" json:"name" jsonschema:"required,title=Variable Name,description=Variable Name"` + Type VarType `yaml:"type" json:"type" jsonschema:"required,type=string,enum=int,enum=string,enum=bool,enum=float,enum=bool,enum=time,enum=duration,title=Variable Type,description=Variable Type"` + Query string `yaml:"query" json:"query" jsonschema:"required,title=Query,description=XPath/Regex Expression to extract the value"` + Value interface{} `yaml:"-" json:"-"` } // NewVariable is the function to create a variable @@ -46,12 +46,12 @@ func NewVariable(name string, t VarType, query string) *Variable { // Evaluator is the structure of evaluator type Evaluator struct { - Variables []Variable `yaml:"variables"` - DocType DocType `yaml:"doc"` - Expression string `yaml:"expression"` - Document string `yaml:"-"` - Extractor Extractor `yaml:"-"` - EvalFuncs map[string]govaluate.ExpressionFunction `yaml:"-"` + Variables []Variable `yaml:"variables,omitempty" json:"variables,omitempty" jsonschema:"title=Variables Definition,description=define the variables used in the expression"` + DocType DocType `yaml:"doc" json:"doc" jsonschema:"required,type=string,enum=html,enum=xml,enum=json,enum=text,title=Document Type,description=Document Type"` + Expression string `yaml:"expression" json:"expression" jsonschema:"required,title=Expression,description=Expression need to be evaluated"` + Document string `yaml:"-" json:"-"` + Extractor Extractor `yaml:"-" json:"-"` + EvalFuncs map[string]govaluate.ExpressionFunction `yaml:"-" json:"-"` } // NewEvaluator is the function to create a evaluator diff --git a/global/global.go b/global/global.go index 948087c5..1475b75d 100644 --- a/global/global.go +++ b/global/global.go @@ -94,16 +94,16 @@ const ( // Retry is the settings of retry type Retry struct { - Times int `yaml:"times"` - Interval time.Duration `yaml:"interval"` + Times int `yaml:"times" json:"times,omitempty" jsonschema:"title=Retry Times,description=how many times need to retry,minimum=1"` + Interval time.Duration `yaml:"interval" json:"interval,omitempty" jsonschema:"type=string,format=duration,title=Retry Interval,description=the interval between each retry"` } // TLS is the configuration for TLS files type TLS struct { - CA string `yaml:"ca"` - Cert string `yaml:"cert"` - Key string `yaml:"key"` - Insecure bool `yaml:"insecure"` + CA string `yaml:"ca" json:"ca,omitempty" jsonschema:"title=CA File,description=the CA file path"` + Cert string `yaml:"cert" json:"cert,omitempty" jsonschema:"title=Cert File,description=the Cert file path"` + Key string `yaml:"key" json:"key,omitempty" jsonschema:"title=Key File,description=the Key file path"` + Insecure bool `yaml:"insecure" json:"insecure,omitempty" jsonschema:"title=Insecure,description=whether to skip the TLS verification"` } // The normalize() function logic as below: diff --git a/go.mod b/go.mod index 4a00f865..bbdfb18b 100644 --- a/go.mod +++ b/go.mod @@ -40,6 +40,8 @@ require ( github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.1 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.15.7 // indirect diff --git a/go.sum b/go.sum index 52ef061f..9ceee685 100644 --- a/go.sum +++ b/go.sum @@ -164,7 +164,11 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -260,6 +264,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= diff --git a/notify/aws/conf.go b/notify/aws/conf.go index c9391029..5d6189db 100644 --- a/notify/aws/conf.go +++ b/notify/aws/conf.go @@ -28,17 +28,17 @@ import ( // Credentials is AWS access id and access token type Credentials struct { - ID string `yaml:"id"` - Secret string `yaml:"key"` + ID string `yaml:"id" json:"id" jsonschema:"required,title=AWS Access Key ID,description=AWS Access Key ID"` + Secret string `yaml:"key" json:"key" jsonschema:"required,title=AWS Access Key Secret,description=AWS Access Key Secret"` } // Options is AWS Configuration type Options struct { base.DefaultNotify `yaml:",inline"` - Region string `yaml:"region"` - Endpoint string `yaml:"endpoint"` - Credentials Credentials `yaml:"credential"` - Profile string `yaml:"profile"` + Region string `yaml:"region" json:"region" jsonschema:"required,title=AWS Region ID,description=AWS Region ID,example=\"us-west-2\""` + Endpoint string `yaml:"endpoint" json:"endpoint" jsonschema:"required,title=AWS Endpoint,description=AWS Endpoint,example=\"https://sns.us-west-2.amazonaws.com\""` + Credentials Credentials `yaml:"credential" json:"credential" jsonschema:"required,title=AWS Credential,description=AWS Credential"` + Profile string `yaml:"profile,omitempty" json:"profile,omitempty" jsonschema:"title=AWS Profile,description=AWS Profile"` session *session.Session `yaml:"-"` } diff --git a/notify/aws/sns.go b/notify/aws/sns.go index 46faf09f..1e5f3a51 100644 --- a/notify/aws/sns.go +++ b/notify/aws/sns.go @@ -27,17 +27,17 @@ import ( log "github.com/sirupsen/logrus" ) -// SNSNotifyConfig is the AWS SNS notification configuration -type SNSNotifyConfig struct { +// NotifyConfig is the AWS SNS notification configuration +type NotifyConfig struct { Options `yaml:",inline"` - Format report.Format `yaml:"format"` - TopicARN string `yaml:"arn"` - client *sns.SNS `yaml:"-"` - context context.Context `yaml:"-"` + Format report.Format `yaml:"format,omitempty" json:"format,omitempty" jsonschema:"type=string,enum=text,enum=html,enum=markdown,enum=json,title=Format of the Notification,description=Format of the notification,default=text"` + TopicARN string `yaml:"arn" json:"arn" jsonschema:"title=Topic ARN,description=The ARN of the SNS topic"` + client *sns.SNS `yaml:"-" json:"-"` + context context.Context `yaml:"-" json:"-"` } // Config configures the slack notification -func (c *SNSNotifyConfig) Config(gConf global.NotifySettings) error { +func (c *NotifyConfig) Config(gConf global.NotifySettings) error { c.NotifyKind = "aws-sns" if c.Format == report.Unknown { c.Format = report.Text @@ -57,12 +57,12 @@ func (c *SNSNotifyConfig) Config(gConf global.NotifySettings) error { } // SendSNS is the warp function of SendSNSNotification -func (c *SNSNotifyConfig) SendSNS(title, msg string) error { +func (c *NotifyConfig) SendSNS(title, msg string) error { return c.SendSNSNotification(msg) } // SendSNSNotification sends the message to SNS -func (c *SNSNotifyConfig) SendSNSNotification(msg string) error { +func (c *NotifyConfig) SendSNSNotification(msg string) error { ctx, cancel := context.WithTimeout(c.context, c.Timeout) defer cancel() diff --git a/notify/aws/sns_test.go b/notify/aws/sns_test.go index c11fb25c..97246a70 100644 --- a/notify/aws/sns_test.go +++ b/notify/aws/sns_test.go @@ -33,7 +33,7 @@ import ( ) func TestSNSConfig(t *testing.T) { - conf := &SNSNotifyConfig{} + conf := &NotifyConfig{} err := conf.Config(global.NotifySettings{}) assert.NoError(t, err) assert.Equal(t, "aws-sns", conf.Kind()) diff --git a/notify/base/base.go b/notify/base/base.go index 9b563e57..77965251 100644 --- a/notify/base/base.go +++ b/notify/base/base.go @@ -29,14 +29,14 @@ import ( // DefaultNotify is the base struct of the Notify type DefaultNotify struct { - NotifyKind string `yaml:"-"` - NotifyFormat report.Format `yaml:"-"` - NotifySendFunc func(string, string) error `yaml:"-"` - NotifyName string `yaml:"name"` - NotifyChannels []string `yaml:"channels"` - Dry bool `yaml:"dry"` - Timeout time.Duration `yaml:"timeout"` - Retry global.Retry `yaml:"retry"` + NotifyKind string `yaml:"-" json:"-"` + NotifyFormat report.Format `yaml:"-" json:"-"` + NotifySendFunc func(string, string) error `yaml:"-" json:"-"` + NotifyName string `yaml:"name" json:"name" jsonschema:"required,title=Notification Name,description=The name of the notification"` + NotifyChannels []string `yaml:"channels,omitempty" json:"channels,omitempty" jsonschema:"title=Notification Channels,description=The channels of the notification"` + Dry bool `yaml:"dry,omitempty" json:"dry,omitempty" jsonschema:"title=Dry Run,description=If true the notification will not send the message"` + Timeout time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty" jsonschema:"format=duration,title=Timeout,description=The timeout of the notification"` + Retry global.Retry `yaml:"retry,omitempty" json:"retry,omitempty" jsonschema:"title=Retry,description=The retry of the notification"` } // Kind returns the kind of the notification diff --git a/notify/dingtalk/dingtalk.go b/notify/dingtalk/dingtalk.go index 4699b029..8677ebea 100644 --- a/notify/dingtalk/dingtalk.go +++ b/notify/dingtalk/dingtalk.go @@ -39,8 +39,8 @@ import ( // NotifyConfig is the dingtalk notification configuration type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - WebhookURL string `yaml:"webhook"` - SignSecret string `yaml:"secret"` + WebhookURL string `yaml:"webhook" json:"webhook" jsonschema:"required,format=uri,title=Webhook URL,description=The Dingtalk Robot Webhook URL"` + SignSecret string `yaml:"secret,omitempty" json:"secret,omitempty" jsonschema:"format=string,title=Secret,description=The Dingtalk Robot Secret"` } // Config configures the dingtalk notification diff --git a/notify/discord/discord.go b/notify/discord/discord.go index a365c234..74a5958c 100644 --- a/notify/discord/discord.go +++ b/notify/discord/discord.go @@ -105,10 +105,10 @@ type Discord struct { // NotifyConfig is the slack notification configuration type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - Username string `yaml:"username"` - WebhookURL string `yaml:"webhook"` - Avatar string `yaml:"avatar"` - Thumbnail string `yaml:"thumbnail"` + Username string `yaml:"username,omitempty" json:"username,omitempty" jsonschema:"title=Username,description=Discord Username for the notification"` + WebhookURL string `yaml:"webhook" json:"webhook" jsonschema:"format=uri,title=Webhook URL,description=Discord Webhook URL for the notification"` + Avatar string `yaml:"avatar,omitempty" json:"avatar,omitempty" jsonschema:"format=uri,title=Avatar,description=Discord Avatar for the notification,example=https://example.com/avatar.png"` + Thumbnail string `yaml:"thumbnail,omitempty" json:"thumbnail,omitempty" jsonschema:"format=uri,title=Thumbnail,description=Discord Thumbnail for the notification,example=https://example.com/thumbnail.png"` } // Config configures the log files diff --git a/notify/email/email.go b/notify/email/email.go index 0e548319..73cddcc6 100644 --- a/notify/email/email.go +++ b/notify/email/email.go @@ -34,11 +34,11 @@ import ( // NotifyConfig is the email notification configuration type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - Server string `yaml:"server"` - User string `yaml:"username"` - Pass string `yaml:"password"` - To string `yaml:"to"` - From string `yaml:"from"` + Server string `yaml:"server" json:"server" jsonschema:"required,format=hostname,title=SMTP Server,description=SMTP server with port,example=\"smtp.example.com:465\""` + User string `yaml:"username" json:"username" jsonschema:"required,title=SMTP Username,description=SMTP username,example=\"name@example.com\""` + Pass string `yaml:"password" json:"password" jsonschema:"required,title=SMTP Password,description=SMTP password,example=\"password\""` + To string `yaml:"to" json:"to" jsonschema:"required,title=To,description=Email address to send,example=\"usera@example.com;userb@example.com\""` + From string `yaml:"from,omitempty" json:"from,omitempty" jsonschema:"title=From,description=Email address from,example=\"from@example.com\""` } // Config configures the log files diff --git a/notify/lark/lark.go b/notify/lark/lark.go index de532903..91d79d66 100644 --- a/notify/lark/lark.go +++ b/notify/lark/lark.go @@ -34,7 +34,7 @@ import ( // NotifyConfig is the slack notification configuration type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - WebhookURL string `yaml:"webhook"` + WebhookURL string `yaml:"webhook" json:"webhook" jsonschema:"required,format=uri,title=Webhook URL,description=The Lark Robot Webhook URL"` } // Config configures the slack notification diff --git a/notify/log/log.go b/notify/log/log.go index 86960b0b..e81177b4 100644 --- a/notify/log/log.go +++ b/notify/log/log.go @@ -47,11 +47,11 @@ const ( type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - File string `yaml:"file"` - Host string `yaml:"host"` - Network string `yaml:"network"` - Type Type `yaml:"-"` - logger *log.Logger + File string `yaml:"file" json:"file,omitempty" jsonschema:"title=Log File,description=The log file to write the notification message"` + Host string `yaml:"host" json:"host,omitempty" jsonschema:"title=Syslog Host,description=The log host to write the notification message"` + Network string `yaml:"network" json:"network,omitempty" jsonschema:"enum=tcp,enum=udp,title=Syslog Network,description=The syslog network to write the notification message"` + Type Type `yaml:"-" json:"-"` + logger *log.Logger `yaml:"-" json:"-"` } func (c *NotifyConfig) configLogFile() error { diff --git a/notify/notify.go b/notify/notify.go index a8eb42ef..821872d0 100644 --- a/notify/notify.go +++ b/notify/notify.go @@ -37,18 +37,18 @@ import ( // Config is the notify configuration type Config struct { - Log []log.NotifyConfig `yaml:"log"` - Email []email.NotifyConfig `yaml:"email"` - Slack []slack.NotifyConfig `yaml:"slack"` - Discord []discord.NotifyConfig `yaml:"discord"` - Telegram []telegram.NotifyConfig `yaml:"telegram"` - AwsSNS []aws.SNSNotifyConfig `yaml:"aws_sns"` - Wecom []wecom.NotifyConfig `yaml:"wecom"` - Dingtalk []dingtalk.NotifyConfig `yaml:"dingtalk"` - Lark []lark.NotifyConfig `yaml:"lark"` - Sms []sms.NotifyConfig `yaml:"sms"` - Teams []teams.NotifyConfig `yaml:"teams"` - Shell []shell.NotifyConfig `yaml:"shell"` + Log []log.NotifyConfig `yaml:"log,omitempty" json:"log,omitempty" jsonschema:"title=Log Notification,description=Log Notification Configuration"` + Email []email.NotifyConfig `yaml:"email,omitempty" json:"email,omitempty" jsonschema:"title=Email Notification,description=Email Notification Configuration"` + Slack []slack.NotifyConfig `yaml:"slack,omitempty" json:"slack,omitempty" jsonschema:"title=Slack Notification,description=Slack Notification Configuration"` + Discord []discord.NotifyConfig `yaml:"discord,omitempty" json:"discord,omitempty" jsonschema:"title=Discord Notification,description=Discord Notification Configuration"` + Telegram []telegram.NotifyConfig `yaml:"telegram,omitempty" json:"telegram,omitempty" jsonschema:"title=Telegram Notification,description=Telegram Notification Configuration"` + AwsSNS []aws.NotifyConfig `yaml:"aws_sns,omitempty" json:"aws_sns,omitempty" jsonschema:"title=AWS SNS Notification,description=AWS SNS Notification Configuration"` + Wecom []wecom.NotifyConfig `yaml:"wecom,omitempty" json:"wecom,omitempty" jsonschema:"title=WeCom Notification,description=WeCom Notification Configuration"` + Dingtalk []dingtalk.NotifyConfig `yaml:"dingtalk,omitempty" json:"dingtalk,omitempty" jsonschema:"title=DingTalk Notification,description=DingTalk Notification Configuration"` + Lark []lark.NotifyConfig `yaml:"lark,omitempty" json:"lark,omitempty" jsonschema:"title=Lark Notification,description=Lark Notification Configuration"` + Sms []sms.NotifyConfig `yaml:"sms,omitempty" json:"sms,omitempty" jsonschema:"title=SMS Notification,description=SMS Notification Configuration"` + Teams []teams.NotifyConfig `yaml:"teams,omitempty" json:"teams,omitempty" jsonschema:"title=Teams Notification,description=Teams Notification Configuration"` + Shell []shell.NotifyConfig `yaml:"shell,omitempty" json:"shell,omitempty" jsonschema:"title=Shell Notification,description=Shell Notification Configuration"` } // Notify is the configuration of the Notify diff --git a/notify/shell/shell.go b/notify/shell/shell.go index a27407d4..cd46d7a7 100644 --- a/notify/shell/shell.go +++ b/notify/shell/shell.go @@ -37,11 +37,11 @@ import ( type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - Cmd string `yaml:"cmd"` - Args []string `yaml:"args"` - Env []string `yaml:"env"` + Cmd string `yaml:"cmd" json:"cmd" jsonschema:"required,title=Command,description=the command to run"` + Args []string `yaml:"args,omitempty" json:"args,omitempty" jsonschema:"title=Arguments,description=the arguments for command"` + Env []string `yaml:"env,omitempty" json:"env,omitempty" jsonschema:"title=Environment variables,description=the environment variables for command"` - CleanEnv bool `yaml:"clean_env"` + CleanEnv bool `yaml:"clean_env,omitempty" json:"clean_env,omitempty" jsonschema:"title=Clean Environment Variables,description=set it to true to keep the environment variables of the current process"` } // Config is the config for shell probe diff --git a/notify/slack/slack.go b/notify/slack/slack.go index 4f66d813..b659a965 100644 --- a/notify/slack/slack.go +++ b/notify/slack/slack.go @@ -33,7 +33,7 @@ import ( // NotifyConfig is the slack notification configuration type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - WebhookURL string `yaml:"webhook"` + WebhookURL string `yaml:"webhook" json:"webhook" jsonschema:"required,format=uri,title=Webhook URL,description=The Slack webhook URL"` } // Config configures the slack notification diff --git a/notify/sms/conf/conf.go b/notify/sms/conf/conf.go index 288b5d70..70b5e466 100644 --- a/notify/sms/conf/conf.go +++ b/notify/sms/conf/conf.go @@ -51,13 +51,13 @@ var ProviderMap = map[ProviderType]string{ type Options struct { base.DefaultNotify `yaml:",inline"` - ProviderType ProviderType `yaml:"provider"` - Mobile string `yaml:"mobile"` - From string `yaml:"from"` - Key string `yaml:"key"` - Secret string `yaml:"secret"` - URL string `yaml:"url"` - Sign string `yaml:"sign"` + ProviderType ProviderType `yaml:"provider" json:"provider" jsonschema:"type=string,enum=yunpian,enum=twilio,enum=nexmo,title=SMS Provider,description=The SMS provider to send the notification message"` + Mobile string `yaml:"mobile" json:"mobile" jsonschema:"title=Mobile,description=The mobile number to send the notification message,example=\"123456789\\,987654321\""` + From string `yaml:"from,omitempty" json:"from,omitempty" jsonschema:"title=From,description=The sender of the notification message"` + Key string `yaml:"key" json:"key" jsonschema:"title=Key,description=The key of the SMS provider"` + Secret string `yaml:"secret,omitempty" json:"secret,omitempty" jsonschema:"title=Secret,description=The secret of the SMS provider"` + URL string `yaml:"url,omitempty" json:"url,omitempty" jsonschema:"format=uri,title=URL,description=The URL of the SMS provider"` + Sign string `yaml:"sign,omitempty" json:"sign,omitempty" jsonschema:"title=Sign,description=The sign of the SMS provider"` } // ProviderTypeMap is the map of provider [name, provider] diff --git a/notify/sms/sms.go b/notify/sms/sms.go index 9b0d11ad..29a52022 100644 --- a/notify/sms/sms.go +++ b/notify/sms/sms.go @@ -35,7 +35,7 @@ type NotifyConfig struct { //Embed structure conf.Options `yaml:",inline"` - Provider conf.Provider `yaml:"-"` + Provider conf.Provider `yaml:"-" json:"-"` } // Config Sms Config Object diff --git a/notify/teams/teams.go b/notify/teams/teams.go index 17f0e648..1f45745a 100644 --- a/notify/teams/teams.go +++ b/notify/teams/teams.go @@ -35,7 +35,7 @@ import ( // NotifyConfig is the teams notification configuration type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - WebhookURL string `yaml:"webhook"` + WebhookURL string `yaml:"webhook" json:"webhook" jsonschema:"required,format=url,title=Webhook URL,description=The Microsoft Teams Robot Webhook URL"` } // Config configures the teams notification diff --git a/notify/telegram/telegram.go b/notify/telegram/telegram.go index 7a02bb78..0b86d96b 100644 --- a/notify/telegram/telegram.go +++ b/notify/telegram/telegram.go @@ -33,8 +33,8 @@ import ( // NotifyConfig is the telegram notification configuration type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - Token string `yaml:"token"` - ChatID string `yaml:"chat_id"` + Token string `yaml:"token" json:"token" jsonschema:"required,title=Telegram Bot Token,description=Telegram Bot Token"` + ChatID string `yaml:"chat_id" json:"chat_id" jsonschema:"required,title=Telegram Chat ID,description=Telegram Group ID or Channel ID"` } // Config configures the telegram configuration diff --git a/notify/wecom/wecom.go b/notify/wecom/wecom.go index 57ba600e..f2a481e6 100644 --- a/notify/wecom/wecom.go +++ b/notify/wecom/wecom.go @@ -33,7 +33,7 @@ import ( // NotifyConfig is the slack notification configuration type NotifyConfig struct { base.DefaultNotify `yaml:",inline"` - WebhookURL string `yaml:"webhook"` + WebhookURL string `yaml:"webhook" json:"webhook" jsonschema:"required,format=url,title=Webhook URL,description=The Webhook URL of Wecom"` } // Config configures the slack notification diff --git a/probe/base/base.go b/probe/base/base.go index e794e7bb..bcd4b0fe 100644 --- a/probe/base/base.go +++ b/probe/base/base.go @@ -44,15 +44,15 @@ type ProbeFuncType func() (bool, string) // DefaultProbe is the default options for all probe type DefaultProbe struct { - ProbeKind string `yaml:"-"` - ProbeTag string `yaml:"-"` - ProbeName string `yaml:"name"` - ProbeChannels []string `yaml:"channels"` - ProbeTimeout time.Duration `yaml:"timeout,omitempty"` - ProbeTimeInterval time.Duration `yaml:"interval,omitempty"` - ProbeFunc ProbeFuncType `yaml:"-"` - ProbeResult *probe.Result `yaml:"-"` - metrics *metrics `yaml:"-"` + ProbeKind string `yaml:"-" json:"-"` + ProbeTag string `yaml:"-" json:"-"` + ProbeName string `yaml:"name" json:"name" jsonschema:"required,title=Probe Name,description=the name of probe must be unique"` + ProbeChannels []string `yaml:"channels" json:"channels,omitempty" jsonschema:"title=Probe Channels,description=the channels of probe message need to send to"` + ProbeTimeout time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty" jsonschema:"type=string,format=duration,title=Probe Timeout,description=the timeout of probe"` + ProbeTimeInterval time.Duration `yaml:"interval,omitempty" json:"interval,omitempty" jsonschema:"type=string,format=duration,title=Probe Interval,description=the interval of probe"` + ProbeFunc ProbeFuncType `yaml:"-" json:"-"` + ProbeResult *probe.Result `yaml:"-" json:"-"` + metrics *metrics `yaml:"-" json:"-"` } // Kind return the probe kind diff --git a/probe/client/client.go b/probe/client/client.go index 5f64418a..c536d7b2 100644 --- a/probe/client/client.go +++ b/probe/client/client.go @@ -39,7 +39,7 @@ type Client struct { //Embed structure conf.Options `yaml:",inline"` - client conf.Driver `yaml:"-"` + client conf.Driver `yaml:"-" json:"-"` } // Config Client Config Object diff --git a/probe/client/conf/conf.go b/probe/client/conf/conf.go index 9708813e..fb58aaaf 100644 --- a/probe/client/conf/conf.go +++ b/probe/client/conf/conf.go @@ -64,11 +64,11 @@ var DriverMap = map[DriverType]string{ type Options struct { base.DefaultProbe `yaml:",inline"` - Host string `yaml:"host"` - DriverType DriverType `yaml:"driver"` - Username string `yaml:"username"` - Password string `yaml:"password"` - Data map[string]string `yaml:"data"` + Host string `yaml:"host" json:"host" jsonschema:"required,format=hostname,title=Host,description=The host of the client,example=10.1.1.1:9000"` + DriverType DriverType `yaml:"driver" json:"driver" jsonschema:"required,type=string,enum=mysql,enum=redis,enum=memcache,enum=kafka,enum=mongo,enum=postgres,enum=zookeeper,title=Driver,description=The driver of the client,example=mysql"` + Username string `yaml:"username,omitempty" json:"username,omitempty" jsonschema:"title=Username,description=The username of the client,example=root"` + Password string `yaml:"password,omitempty" json:"password,omitempty" jsonschema:"title=Password,description=The password of the client,example=123456"` + Data map[string]string `yaml:"data,omitempty" json:"data,omitempty" jsonschema:"title=Data,description=The data of the client,example={\"key\":\"value\"}"` //TLS global.TLS `yaml:",inline"` diff --git a/probe/client/kafka/kafka.go b/probe/client/kafka/kafka.go index bc0a71c4..af61e232 100644 --- a/probe/client/kafka/kafka.go +++ b/probe/client/kafka/kafka.go @@ -35,8 +35,8 @@ const Kind string = "Kafka" // Kafka is the Kafka client type Kafka struct { conf.Options `yaml:",inline"` - tls *tls.Config `yaml:"-"` - Context context.Context `yaml:"-"` + tls *tls.Config `yaml:"-" json:"-"` + Context context.Context `yaml:"-" json:"-"` } // New create a Kafka client diff --git a/probe/client/memcache/memcache.go b/probe/client/memcache/memcache.go index 85123751..b1327e5b 100644 --- a/probe/client/memcache/memcache.go +++ b/probe/client/memcache/memcache.go @@ -34,7 +34,7 @@ const Kind string = "Memcache" // Memcache is the Memcache client type Memcache struct { conf.Options `yaml:",inline"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-" json:"-"` } // New create a Memcache client diff --git a/probe/client/mongo/mongo.go b/probe/client/mongo/mongo.go index 5c9567c0..809c56d6 100644 --- a/probe/client/mongo/mongo.go +++ b/probe/client/mongo/mongo.go @@ -37,9 +37,9 @@ const Kind string = "Mongo" // Mongo is the Mongo client type Mongo struct { conf.Options `yaml:",inline"` - ConnStr string `yaml:"conn_str"` - ClientOpt *options.ClientOptions `yaml:"-"` - Context context.Context `yaml:"-"` + ConnStr string `yaml:"conn_str,omitempty" json:"conn_str,omitempty"` + ClientOpt *options.ClientOptions `yaml:"-" json:"-"` + Context context.Context `yaml:"-" json:"-"` } // New create a Mongo client diff --git a/probe/client/mysql/mysql.go b/probe/client/mysql/mysql.go index 963f1df8..572a3308 100644 --- a/probe/client/mysql/mysql.go +++ b/probe/client/mysql/mysql.go @@ -38,8 +38,8 @@ const Kind string = "MySQL" // MySQL is the MySQL client type MySQL struct { conf.Options `yaml:",inline"` - tls *tls.Config `yaml:"-"` - ConnStr string `yaml:"conn_str"` + tls *tls.Config `yaml:"-" json:"-"` + ConnStr string `yaml:"conn_str,omitempty" json:"conn_str,omitempty"` } // New create a Mysql client diff --git a/probe/client/postgres/postgres.go b/probe/client/postgres/postgres.go index 558cd2b1..d0161944 100644 --- a/probe/client/postgres/postgres.go +++ b/probe/client/postgres/postgres.go @@ -38,7 +38,7 @@ const Kind string = "PostgreSQL" // PostgreSQL is the PostgreSQL client type PostgreSQL struct { conf.Options `yaml:",inline"` - ClientOptions []pgdriver.Option `yaml:"-"` + ClientOptions []pgdriver.Option `yaml:"-" json:"-"` } // revive:enable diff --git a/probe/client/redis/redis.go b/probe/client/redis/redis.go index 2a0dd47e..716bffc8 100644 --- a/probe/client/redis/redis.go +++ b/probe/client/redis/redis.go @@ -34,8 +34,8 @@ const Kind string = "Redis" // Redis is the Redis client type Redis struct { conf.Options `yaml:",inline"` - tls *tls.Config `yaml:"-"` - Context context.Context `yaml:"-"` + tls *tls.Config `yaml:"-" json:"-"` + Context context.Context `yaml:"-" json:"-"` } // New create a Redis client diff --git a/probe/client/zookeeper/zookeeper.go b/probe/client/zookeeper/zookeeper.go index c2f2ab38..f8165ba4 100644 --- a/probe/client/zookeeper/zookeeper.go +++ b/probe/client/zookeeper/zookeeper.go @@ -36,8 +36,8 @@ const Kind string = "ZooKeeper" // Zookeeper is the Zookeeper client type Zookeeper struct { conf.Options `yaml:",inline"` - tls *tls.Config `yaml:"-"` - Context context.Context `yaml:"conn_str"` + tls *tls.Config `yaml:"-" json:"-"` + Context context.Context `yaml:"conn_str,omitempty" json:"conn_str,omitempty"` } // New create a Zookeeper client diff --git a/probe/common.go b/probe/common.go index fa36730c..92e1fea3 100644 --- a/probe/common.go +++ b/probe/common.go @@ -25,12 +25,12 @@ import ( // TextChecker is the struct to check the output type TextChecker struct { - Contain string `yaml:"contain,omitempty"` - NotContain string `yaml:"not_contain,omitempty"` - RegExp bool `yaml:"regex,omitempty"` + Contain string `yaml:"contain,omitempty" json:"contain,omitempty" jsonschema:"title=Contain Text,description=the string must be contained"` + NotContain string `yaml:"not_contain,omitempty" json:"not_contain,omitempty" jsonschema:"title=Not Contain Text,description=the string must not be contained"` + RegExp bool `yaml:"regex,omitempty" json:"regex,omitempty" jsonschema:"title=regex,description=use regular expression to check the contain or not contain"` - containReg *regexp.Regexp `yaml:"-"` - notContainReg *regexp.Regexp `yaml:"-"` + containReg *regexp.Regexp `yaml:"-" json:"-"` + notContainReg *regexp.Regexp `yaml:"-" json:"-"` } // Config the text checker initialize the regexp diff --git a/probe/host/host.go b/probe/host/host.go index 54b5631d..5583abc5 100644 --- a/probe/host/host.go +++ b/probe/host/host.go @@ -39,9 +39,9 @@ const ( // Threshold is the threshold of a probe type Threshold struct { - CPU float64 `yaml:"cpu"` - Mem float64 `yaml:"mem"` - Disk float64 `yaml:"disk"` + CPU float64 `yaml:"cpu,omitempty" json:"cpu,omitempty" jsonschema:"title=CPU threshold,description=CPU threshold (default: 0.8)"` + Mem float64 `yaml:"mem,omitempty" json:"mem,omitempty" jsonschema:"title=Memory threshold,description=Memory threshold (default: 0.8)"` + Disk float64 `yaml:"disk,omitempty" json:"disk,omitempty" jsonschema:"title=Disk threshold,description=Disk threshold (default: 0.95)"` } func (t *Threshold) String() string { @@ -51,15 +51,15 @@ func (t *Threshold) String() string { // Server is the server of a host probe type Server struct { ssh.Server `yaml:",inline"` - Threshold Threshold `yaml:"threshold"` - Disks []string `yaml:"disks"` - metrics *metrics `yaml:"-"` + Threshold Threshold `yaml:"threshold,omitempty" json:"threshold,omitempty" jsonschema:"title=Threshold,description=the threshold of the probe for cpu/memory/disk"` + Disks []string `yaml:"disks,omitempty" json:"disks,omitempty" jsonschema:"title=Disks,description=the disks to be monitored,example=[\"/\", \"/data\"]"` + metrics *metrics `yaml:"-" json:"-"` } // Host is the host probe configuration type Host struct { - Bastion *ssh.BastionMapType `yaml:"bastion"` - Servers []Server `yaml:"servers"` + Bastion *ssh.BastionMapType `yaml:"bastion,omitempty" json:"bastion,omitempty" jsonschema:"title=Bastion Servers,description=the bastion server for ssh login"` + Servers []Server `yaml:"servers" json:"servers" jsonschema:"required,title=Host Servers,description=the host servers to be monitored"` } // BastionMap is a map of bastion diff --git a/probe/http/http.go b/probe/http/http.go index 84a6385e..a43bfb2d 100644 --- a/probe/http/http.go +++ b/probe/http/http.go @@ -42,35 +42,35 @@ import ( // HTTP implements a config for HTTP. type HTTP struct { base.DefaultProbe `yaml:",inline"` - URL string `yaml:"url"` - Proxy string `yaml:"proxy"` - ContentEncoding string `yaml:"content_encoding,omitempty"` - Method string `yaml:"method,omitempty"` - Headers map[string]string `yaml:"headers,omitempty"` - Body string `yaml:"body,omitempty"` + URL string `yaml:"url" json:"url" jsonschema:"format=uri,title=HTTP URL,description=HTTP URL to probe"` + Proxy string `yaml:"proxy" json:"proxy,omitempty" jsonschema:"format=url,title=Proxy Server,description=proxy to use for HTTP requests"` + ContentEncoding string `yaml:"content_encoding,omitempty" json:"content_encoding,omitempty" jsonschema:"title=Content Encoding,description=content encoding to use for HTTP requests"` + Method string `yaml:"method,omitempty" json:"method,omitempty" jsonschema:"enum=GET,enum=POST,enum=DELETE,enum=PUT,enum=HEAD,enum=OPTIONS,enum=PATCH,enum=TRACE,enum=CONNECT,title=HTTP Method,description=HTTP method to use for HTTP requests"` + Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty" jsonschema:"title=HTTP Headers,description=HTTP headers to use for HTTP requests"` + Body string `yaml:"body,omitempty" json:"body,omitempty" jsonschema:"title=HTTP Body,description=HTTP body to use for HTTP requests"` // Output Text Checker probe.TextChecker `yaml:",inline"` // Evaluator - Evaluator eval.Evaluator `yaml:"eval,omitempty"` + Evaluator eval.Evaluator `yaml:"eval,omitempty" json:"eval,omitempty" jsonschema:"title=HTTP Evaluator,description=HTTP evaluator to use for HTTP requests"` // Option - HTTP Basic Auth Credentials - User string `yaml:"username,omitempty"` - Pass string `yaml:"password,omitempty"` + User string `yaml:"username,omitempty" json:"username,omitempty" jsonschema:"title=HTTP Basic Auth Username,description=HTTP Basic Auth Username"` + Pass string `yaml:"password,omitempty" json:"password,omitempty" jsonschema:"title=HTTP Basic Auth Password,description=HTTP Basic Auth Password"` - // Option - Preferred HTTP response code ranges, only HTTP standard codes(smaller than 500) are supported; - // If no set, default is [0, 499]. - SuccessCode [][]int `yaml:"success_code,omitempty"` + // Option - Preferred HTTP response code ranges + // If not set, default is [0, 499]. + SuccessCode [][]int `yaml:"success_code,omitempty" json:"success_code,omitempty" jsonschema:"title=HTTP Success Code Range,description=Preferred HTTP response code ranges. If not set the default is [0\\, 499]."` // Option - TLS Config global.TLS `yaml:",inline"` - client *http.Client `yaml:"-"` + client *http.Client `yaml:"-" json:"-"` - traceStats *TraceStats `yaml:"-"` + traceStats *TraceStats `yaml:"-" json:"-"` - metrics *metrics `yaml:"-"` + metrics *metrics `yaml:"-" json:"-"` } func checkHTTPMethod(m string) bool { diff --git a/probe/shell/shell.go b/probe/shell/shell.go index ef824bff..0adcc531 100644 --- a/probe/shell/shell.go +++ b/probe/shell/shell.go @@ -34,18 +34,18 @@ import ( // Shell implements a config for shell command (os.Exec) type Shell struct { base.DefaultProbe `yaml:",inline"` - Command string `yaml:"cmd"` - Args []string `yaml:"args,omitempty"` - Env []string `yaml:"env,omitempty"` - CleanEnv bool `yaml:"clean_env,omitempty"` + Command string `yaml:"cmd" json:"cmd" jsonschema:"required,title=Command Line,description=Command Line"` + Args []string `yaml:"args,omitempty" json:"args,omitempty" jsonschema:"title=Command Line Arguments,description=Command Line Arguments"` + Env []string `yaml:"env,omitempty" json:"env,omitempty" jsonschema:"title=Environment Variables,description=Environment Variables,example=[\"PATH=/usr/local/bin\"]"` + CleanEnv bool `yaml:"clean_env,omitempty" json:"clean_env,omitempty" jsonschema:"title=Clean Environment,description=set it to true to keep the environment variables of the current process"` // Output Text Checker probe.TextChecker `yaml:",inline"` - exitCode int `yaml:"-"` - outputLen int `yaml:"-"` + exitCode int `yaml:"-" json:"-"` + outputLen int `yaml:"-" json:"-"` - metrics *metrics `yaml:"-"` + metrics *metrics `yaml:"-" json:"-"` } // Config Shell Config Object diff --git a/probe/ssh/endpoint.go b/probe/ssh/endpoint.go index a4188e18..8bae1692 100644 --- a/probe/ssh/endpoint.go +++ b/probe/ssh/endpoint.go @@ -29,12 +29,12 @@ import ( // Endpoint is SSH Endpoint type Endpoint struct { - PrivateKey string `yaml:"key"` - Host string `yaml:"host"` - User string `yaml:"username"` - Password string `yaml:"password"` - Passphrase string `yaml:"passphrase"` - client *ssh.Client `yaml:"-"` + PrivateKey string `yaml:"key" json:"key,omitempty" jsonschema:"title=Private Key,description=the private key file path for ssh login"` + Passphrase string `yaml:"passphrase" json:"passphrase,omitempty" jsonschema:"title=Passphrase,description=the passphrase for ssh private key"` + Host string `yaml:"host" json:"host" jsonschema:"required,format=hostname,title=Host,description=the host for ssh probe"` + User string `yaml:"username" json:"username,omitempty" jsonschema:"title=User,description=the username for ssh probe"` + Password string `yaml:"password" json:"password,omitempty" jsonschema:"title=Password,description=the password for ssh probe"` + client *ssh.Client `yaml:"-" json:"-"` } // ParseHost check the host is configured the port or not diff --git a/probe/ssh/ssh.go b/probe/ssh/ssh.go index f55f32d0..96887756 100644 --- a/probe/ssh/ssh.go +++ b/probe/ssh/ssh.go @@ -39,26 +39,26 @@ const Kind string = "ssh" type Server struct { base.DefaultProbe `yaml:",inline"` Endpoint `yaml:",inline"` - Command string `yaml:"cmd"` - Args []string `yaml:"args,omitempty"` - Env []string `yaml:"env,omitempty"` + Command string `yaml:"cmd" json:"cmd,omitempty" jsonschema:"title=Shell Command,description=command to run"` + Args []string `yaml:"args,omitempty" json:"args,omitempty" jsonschema:"title=Shell Command Arguments,description=arguments for the command"` + Env []string `yaml:"env,omitempty" json:"env,omitempty" jsonschema:"title=Environment Variables,description=environment variables for the command"` // Output Text Checker probe.TextChecker `yaml:",inline"` - BastionID string `yaml:"bastion"` - bastion *Endpoint `yaml:"-"` + BastionID string `yaml:"bastion" json:"bastion,omitempty" jsonschema:"title=Bastion Server,description=the bastion host id"` + bastion *Endpoint `yaml:"-" json:"-"` - exitCode int `yaml:"-"` - outputLen int `yaml:"-"` + exitCode int `yaml:"-" json:"-"` + outputLen int `yaml:"-" json:"-"` - metrics *metrics `yaml:"-"` + metrics *metrics `yaml:"-" json:"-"` } // SSH is the SSH probe Configuration type SSH struct { - Bastion *BastionMapType `yaml:"bastion"` - Servers []Server `yaml:"servers"` + Bastion *BastionMapType `yaml:"bastion" json:"bastion,omitempty" jsonschema:"title=Bastion Servers,description=the bastion hosts configuration"` + Servers []Server `yaml:"servers" json:"servers" jsonschema:"required,title=SSH Servers,description=SSH servers to probe"` } // BastionMapType is the type of bastion diff --git a/probe/tcp/tcp.go b/probe/tcp/tcp.go index 26d2ae43..60b5205c 100644 --- a/probe/tcp/tcp.go +++ b/probe/tcp/tcp.go @@ -30,8 +30,8 @@ import ( // TCP implements a config for TCP type TCP struct { base.DefaultProbe `yaml:",inline"` - Host string `yaml:"host"` - Proxy string `yaml:"proxy"` + Host string `yaml:"host" json:"host" jsonschema:"required,format=hostname,title=Host,description=The host to probe"` + Proxy string `yaml:"proxy" json:"proxy,omitempty" jsonschema:"format=hostname,title=Proxy,description=The proxy to use"` } // Config HTTP Config Object diff --git a/probe/tls/tls.go b/probe/tls/tls.go index 620e5e9c..0b510d42 100644 --- a/probe/tls/tls.go +++ b/probe/tls/tls.go @@ -38,16 +38,16 @@ import ( // TLS implements a config for TLS type TLS struct { base.DefaultProbe `yaml:",inline"` - Host string `yaml:"host"` - Proxy string `yaml:"proxy"` - InsecureSkipVerify bool `yaml:"insecure_skip_verify"` + Host string `yaml:"host" json:"host" jsonschema:"required,format=hostname,title=Host,description=The host to probe"` + Proxy string `yaml:"proxy" json:"proxy,omitempty" jsonschema:"format=hostname,title=Proxy,description=The proxy to use for the TLS connection"` + InsecureSkipVerify bool `yaml:"insecure_skip_verify" json:"insecure_skip_verify,omitempty" jsonschema:"title=Insecure Skip Verify,description=Whether to skip verifying the certificate chain and host name"` - RootCAPemPath string `yaml:"root_ca_pem_path"` - RootCaPem string `yaml:"root_ca_pem"` - rootCAs *x509.CertPool + RootCAPemPath string `yaml:"root_ca_pem_path" json:"root_ca_pem_path,omitempty" jsonschema:"title=Root CA PEM Path,description=The path to the root CA PEM file"` + RootCaPem string `yaml:"root_ca_pem" json:"root_ca_pem,omitempty" jsonschema:"title=Root CA PEM,description=The root CA PEM"` + rootCAs *x509.CertPool `yaml:"-" json:"-"` - ExpireSkipVerify bool `yaml:"expire_skip_verify"` - AlertExpireBefore time.Duration `yaml:"alert_expire_before"` + ExpireSkipVerify bool `yaml:"expire_skip_verify" json:"expire_skip_verify,omitempty" jsonschema:"title=Expire Skip Verify,description=Whether to skip verifying the certificate expire time"` + AlertExpireBefore time.Duration `yaml:"alert_expire_before" json:"alert_expire_before,omitempty" jsonschema:"title=Alert Expire Before,description=The alert expire before time"` metrics *metrics } diff --git a/resources/schema.json b/resources/schema.json new file mode 100644 index 00000000..3c54a3b4 --- /dev/null +++ b/resources/schema.json @@ -0,0 +1,1990 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/megaease/easeprobe/conf/conf_-conf", + "$ref": "#/$defs/conf_Conf", + "$defs": { + "BastionMapType": { + "patternProperties": { + ".*": { + "$ref": "#/$defs/probe_ssh_Endpoint" + } + }, + "type": "object" + }, + "conf_Conf": { + "properties": { + "version": { + "type": "string", + "title": "Version", + "description": "Version of the EaseProbe configuration" + }, + "http": { + "items": { + "$ref": "#/$defs/probe_http_HTTP" + }, + "type": "array", + "title": "HTTP Probe", + "description": "HTTP Probe Configuration" + }, + "tcp": { + "items": { + "$ref": "#/$defs/probe_tcp_TCP" + }, + "type": "array", + "title": "TCP Probe", + "description": "TCP Probe Configuration" + }, + "shell": { + "items": { + "$ref": "#/$defs/probe_shell_Shell" + }, + "type": "array", + "title": "Shell Probe", + "description": "Shell Probe Configuration" + }, + "client": { + "items": { + "$ref": "#/$defs/probe_client_Client" + }, + "type": "array", + "title": "Native Client Probe", + "description": "Native Client Probe Configuration" + }, + "ssh": { + "$ref": "#/$defs/probe_ssh_SSH", + "title": "SSH Probe", + "description": "SSH Probe Configuration" + }, + "tls": { + "items": { + "$ref": "#/$defs/probe_tls_TLS" + }, + "type": "array", + "title": "TLS Probe", + "description": "TLS Probe Configuration" + }, + "host": { + "$ref": "#/$defs/probe_host_Host", + "title": "Host Probe", + "description": "Host Probe Configuration" + }, + "notify": { + "$ref": "#/$defs/notify_Config", + "title": "Notification", + "description": "Notification Configuration" + }, + "settings": { + "$ref": "#/$defs/conf_Settings", + "title": "Global Settings", + "description": "EaseProbe Global configuration" + } + }, + "additionalProperties": false, + "type": "object" + }, + "conf_HTTPServer": { + "properties": { + "ip": { + "type": "string", + "title": "Web Server IP", + "description": "the local ip address of the http server need to listen on", + "examples": [ + "0.0.0.0" + ] + }, + "port": { + "type": "integer", + "title": "Web Server Port", + "description": "port of the http server", + "default": 8181 + }, + "refresh": { + "type": "string", + "title": "Auto Refresh Time", + "description": "auto refresh time of the http server", + "examples": [ + "5s" + ] + }, + "log": { + "$ref": "#/$defs/conf_Log", + "title": "Access Log", + "description": "access log of the http server" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "ip", + "port" + ] + }, + "conf_Log": { + "properties": { + "level": { + "type": "string", + "enum": [ + "debug", + "info", + "warn", + "error", + "fatal", + "panic" + ], + "title": "Log Level", + "description": "Log Level" + }, + "file": { + "type": "string", + "title": "Log File", + "description": "the file to save the log" + }, + "self_rotate": { + "type": "boolean", + "title": "Self Rotate", + "description": "whether to rotate the log file by self" + }, + "size": { + "type": "integer", + "title": "Max Size", + "description": "the max size of the log file. the log file will be rotated if the size is larger than this value" + }, + "age": { + "type": "integer", + "title": "Max Age", + "description": "the max age of the log file. the log file will be rotated if the age is larger than this value" + }, + "backups": { + "type": "integer", + "title": "Max Backups", + "description": "the max backups of the log file. the rotated log file will be deleted if the backups is larger than this value" + }, + "compress": { + "type": "boolean", + "title": "Compress", + "description": "whether to compress the rotated log file" + } + }, + "additionalProperties": false, + "type": "object" + }, + "conf_Notify": { + "properties": { + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "retry", + "description": "the retry settings" + }, + "dry": { + "type": "boolean", + "title": "dry", + "description": "set true to make the notification dry run and will not be sent the message", + "default": false + } + }, + "additionalProperties": false, + "type": "object" + }, + "conf_Probe": { + "properties": { + "interval": { + "type": "string", + "title": "Probe Interval", + "description": "the interval of probe", + "default": "1m" + }, + "timeout": { + "type": "string", + "title": "Probe Timeout", + "description": "the timeout of probe", + "default": "30s" + } + }, + "additionalProperties": false, + "type": "object" + }, + "conf_SLAReport": { + "properties": { + "schedule": { + "type": "string", + "enum": [ + "none", + "hourly", + "daily", + "weekly", + "monthly" + ], + "title": "Schedule", + "description": "the schedule of SLA report" + }, + "time": { + "type": "string", + "title": "Time", + "description": "the time of SLA report need to send out", + "examples": [ + "23:59:59+08:00" + ] + }, + "debug": { + "type": "boolean", + "title": "Debug", + "description": "if true the SLA report will be printed to stdout", + "default": false + }, + "data": { + "type": "string", + "title": "Data File", + "description": "the data file of SLA report" + }, + "backups": { + "type": "integer", + "title": "Backups", + "description": "the number of backups of SLA report", + "default": 5 + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Channels", + "description": "the channels of SLA report" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "schedule" + ] + }, + "conf_Settings": { + "properties": { + "name": { + "type": "string", + "title": "EaseProbe Name", + "description": "The name of the EaseProbe instance", + "default": "EaseProbe" + }, + "icon": { + "type": "string", + "title": "Icon URL", + "description": "The URL of the icon of the EaseProbe instance" + }, + "pid": { + "type": "string", + "title": "PID File", + "description": "The PID file of the EaseProbe instance ('-' means no PID file)" + }, + "log": { + "$ref": "#/$defs/conf_Log", + "title": "EaseProbe Log", + "description": "The log settings of the EaseProbe instance" + }, + "timeformat": { + "type": "string", + "title": "Time Format", + "description": "The time format of the EaseProbe instance", + "default": "2006-01-02 15:04:05Z07:00" + }, + "timezone": { + "type": "string", + "title": "Time Zone", + "description": "The time zone of the EaseProbe instance", + "default": "UTC", + "examples": [ + "Asia/Shanghai", + "Europe/Berlin" + ] + }, + "probe": { + "$ref": "#/$defs/conf_Probe", + "title": "Probe Settings", + "description": "The global probe settings of the EaseProbe instance" + }, + "notify": { + "$ref": "#/$defs/conf_Notify", + "title": "Notify Settings", + "description": "The global notify settings of the EaseProbe instance" + }, + "sla": { + "$ref": "#/$defs/conf_SLAReport", + "title": "SLA Report Settings", + "description": "The SLA report settings of the EaseProbe instance" + }, + "http": { + "$ref": "#/$defs/conf_HTTPServer", + "title": "HTTP Server Settings", + "description": "The HTTP server settings of the EaseProbe instance" + } + }, + "additionalProperties": false, + "type": "object" + }, + "eval_Evaluator": { + "properties": { + "variables": { + "items": { + "$ref": "#/$defs/eval_Variable" + }, + "type": "array", + "title": "Variables Definition", + "description": "define the variables used in the expression" + }, + "doc": { + "type": "string", + "enum": [ + "html", + "xml", + "json", + "text" + ], + "title": "Document Type", + "description": "Document Type" + }, + "expression": { + "type": "string", + "title": "Expression", + "description": "Expression need to be evaluated" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "doc", + "expression" + ] + }, + "eval_Variable": { + "properties": { + "name": { + "type": "string", + "title": "Variable Name", + "description": "Variable Name" + }, + "type": { + "type": "string", + "enum": [ + "int", + "string", + "bool", + "float", + "bool", + "time", + "duration" + ], + "title": "Variable Type", + "description": "Variable Type" + }, + "query": { + "type": "string", + "title": "Query", + "description": "XPath/Regex Expression to extract the value" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "type", + "query" + ] + }, + "global_Retry": { + "properties": { + "times": { + "type": "integer", + "minimum": 1, + "title": "Retry Times", + "description": "how many times need to retry" + }, + "interval": { + "type": "string", + "title": "Retry Interval", + "description": "the interval between each retry" + } + }, + "additionalProperties": false, + "type": "object" + }, + "notify_Config": { + "properties": { + "log": { + "items": { + "$ref": "#/$defs/notify_log_NotifyConfig" + }, + "type": "array", + "title": "Log Notification", + "description": "Log Notification Configuration" + }, + "email": { + "items": { + "$ref": "#/$defs/notify_email_NotifyConfig" + }, + "type": "array", + "title": "Email Notification", + "description": "Email Notification Configuration" + }, + "slack": { + "items": { + "$ref": "#/$defs/notify_slack_NotifyConfig" + }, + "type": "array", + "title": "Slack Notification", + "description": "Slack Notification Configuration" + }, + "discord": { + "items": { + "$ref": "#/$defs/notify_discord_NotifyConfig" + }, + "type": "array", + "title": "Discord Notification", + "description": "Discord Notification Configuration" + }, + "telegram": { + "items": { + "$ref": "#/$defs/notify_telegram_NotifyConfig" + }, + "type": "array", + "title": "Telegram Notification", + "description": "Telegram Notification Configuration" + }, + "aws_sns": { + "items": { + "$ref": "#/$defs/notify_aws_NotifyConfig" + }, + "type": "array", + "title": "AWS SNS Notification", + "description": "AWS SNS Notification Configuration" + }, + "wecom": { + "items": { + "$ref": "#/$defs/notify_wecom_NotifyConfig" + }, + "type": "array", + "title": "WeCom Notification", + "description": "WeCom Notification Configuration" + }, + "dingtalk": { + "items": { + "$ref": "#/$defs/notify_dingtalk_NotifyConfig" + }, + "type": "array", + "title": "DingTalk Notification", + "description": "DingTalk Notification Configuration" + }, + "lark": { + "items": { + "$ref": "#/$defs/notify_lark_NotifyConfig" + }, + "type": "array", + "title": "Lark Notification", + "description": "Lark Notification Configuration" + }, + "sms": { + "items": { + "$ref": "#/$defs/notify_sms_NotifyConfig" + }, + "type": "array", + "title": "SMS Notification", + "description": "SMS Notification Configuration" + }, + "teams": { + "items": { + "$ref": "#/$defs/notify_teams_NotifyConfig" + }, + "type": "array", + "title": "Teams Notification", + "description": "Teams Notification Configuration" + }, + "shell": { + "items": { + "$ref": "#/$defs/notify_shell_NotifyConfig" + }, + "type": "array", + "title": "Shell Notification", + "description": "Shell Notification Configuration" + } + }, + "additionalProperties": false, + "type": "object" + }, + "notify_aws_Credentials": { + "properties": { + "id": { + "type": "string", + "title": "AWS Access Key ID", + "description": "AWS Access Key ID" + }, + "key": { + "type": "string", + "title": "AWS Access Key Secret", + "description": "AWS Access Key Secret" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "id", + "key" + ] + }, + "notify_aws_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "region": { + "type": "string", + "title": "AWS Region ID", + "description": "AWS Region ID", + "examples": [ + "\"us-west-2\"" + ] + }, + "endpoint": { + "type": "string", + "title": "AWS Endpoint", + "description": "AWS Endpoint", + "examples": [ + "\"https://sns.us-west-2.amazonaws.com\"" + ] + }, + "credential": { + "$ref": "#/$defs/notify_aws_Credentials", + "title": "AWS Credential", + "description": "AWS Credential" + }, + "profile": { + "type": "string", + "title": "AWS Profile", + "description": "AWS Profile" + }, + "format": { + "type": "string", + "enum": [ + "text", + "html", + "markdown", + "json" + ], + "title": "Format of the Notification", + "description": "Format of the notification", + "default": "text" + }, + "arn": { + "type": "string", + "title": "Topic ARN", + "description": "The ARN of the SNS topic" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "region", + "endpoint", + "credential", + "arn" + ] + }, + "notify_dingtalk_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "webhook": { + "type": "string", + "format": "uri", + "title": "Webhook URL", + "description": "The Dingtalk Robot Webhook URL" + }, + "secret": { + "type": "string", + "title": "Secret", + "description": "The Dingtalk Robot Secret" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "webhook" + ] + }, + "notify_discord_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "username": { + "type": "string", + "title": "Username", + "description": "Discord Username for the notification" + }, + "webhook": { + "type": "string", + "format": "uri", + "title": "Webhook URL", + "description": "Discord Webhook URL for the notification" + }, + "avatar": { + "type": "string", + "format": "uri", + "title": "Avatar", + "description": "Discord Avatar for the notification", + "examples": [ + "https://example.com/avatar.png" + ] + }, + "thumbnail": { + "type": "string", + "format": "uri", + "title": "Thumbnail", + "description": "Discord Thumbnail for the notification", + "examples": [ + "https://example.com/thumbnail.png" + ] + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "webhook" + ] + }, + "notify_email_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "server": { + "type": "string", + "format": "hostname", + "title": "SMTP Server", + "description": "SMTP server with port", + "examples": [ + "\"smtp.example.com:465\"" + ] + }, + "username": { + "type": "string", + "title": "SMTP Username", + "description": "SMTP username", + "examples": [ + "\"name@example.com\"" + ] + }, + "password": { + "type": "string", + "title": "SMTP Password", + "description": "SMTP password", + "examples": [ + "\"password\"" + ] + }, + "to": { + "type": "string", + "title": "To", + "description": "Email address to send", + "examples": [ + "\"usera@example.com;userb@example.com\"" + ] + }, + "from": { + "type": "string", + "title": "From", + "description": "Email address from", + "examples": [ + "\"from@example.com\"" + ] + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "server", + "username", + "password", + "to" + ] + }, + "notify_lark_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "webhook": { + "type": "string", + "format": "uri", + "title": "Webhook URL", + "description": "The Lark Robot Webhook URL" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "webhook" + ] + }, + "notify_log_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "file": { + "type": "string", + "title": "Log File", + "description": "The log file to write the notification message" + }, + "host": { + "type": "string", + "title": "Syslog Host", + "description": "The log host to write the notification message" + }, + "network": { + "type": "string", + "enum": [ + "tcp", + "udp" + ], + "title": "Syslog Network", + "description": "The syslog network to write the notification message" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name" + ] + }, + "notify_shell_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "cmd": { + "type": "string", + "title": "Command", + "description": "the command to run" + }, + "args": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Arguments", + "description": "the arguments for command" + }, + "env": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Environment variables", + "description": "the environment variables for command" + }, + "clean_env": { + "type": "boolean", + "title": "Clean Environment Variables", + "description": "set it to true to keep the environment variables of the current process" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "cmd" + ] + }, + "notify_slack_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "webhook": { + "type": "string", + "format": "uri", + "title": "Webhook URL", + "description": "The Slack webhook URL" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "webhook" + ] + }, + "notify_sms_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "provider": { + "type": "string", + "enum": [ + "yunpian", + "twilio", + "nexmo" + ], + "title": "SMS Provider", + "description": "The SMS provider to send the notification message" + }, + "mobile": { + "type": "string", + "title": "Mobile", + "description": "The mobile number to send the notification message", + "examples": [ + "\"123456789,987654321\"" + ] + }, + "from": { + "type": "string", + "title": "From", + "description": "The sender of the notification message" + }, + "key": { + "type": "string", + "title": "Key", + "description": "The key of the SMS provider" + }, + "secret": { + "type": "string", + "title": "Secret", + "description": "The secret of the SMS provider" + }, + "url": { + "type": "string", + "format": "uri", + "title": "URL", + "description": "The URL of the SMS provider" + }, + "sign": { + "type": "string", + "title": "Sign", + "description": "The sign of the SMS provider" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "provider", + "mobile", + "key" + ] + }, + "notify_teams_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "webhook": { + "type": "string", + "title": "Webhook URL", + "description": "The Microsoft Teams Robot Webhook URL" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "webhook" + ] + }, + "notify_telegram_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "token": { + "type": "string", + "title": "Telegram Bot Token", + "description": "Telegram Bot Token" + }, + "chat_id": { + "type": "string", + "title": "Telegram Chat ID", + "description": "Telegram Group ID or Channel ID" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "token", + "chat_id" + ] + }, + "notify_wecom_NotifyConfig": { + "properties": { + "name": { + "type": "string", + "title": "Notification Name", + "description": "The name of the notification" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Notification Channels", + "description": "The channels of the notification" + }, + "dry": { + "type": "boolean", + "title": "Dry Run", + "description": "If true the notification will not send the message" + }, + "timeout": { + "type": "integer", + "title": "Timeout", + "description": "The timeout of the notification" + }, + "retry": { + "$ref": "#/$defs/global_Retry", + "title": "Retry", + "description": "The retry of the notification" + }, + "webhook": { + "type": "string", + "title": "Webhook URL", + "description": "The Webhook URL of Wecom" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "webhook" + ] + }, + "probe_client_Client": { + "properties": { + "name": { + "type": "string", + "title": "Probe Name", + "description": "the name of probe must be unique" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Probe Channels", + "description": "the channels of probe message need to send to" + }, + "timeout": { + "type": "string", + "title": "Probe Timeout", + "description": "the timeout of probe" + }, + "interval": { + "type": "string", + "title": "Probe Interval", + "description": "the interval of probe" + }, + "host": { + "type": "string", + "format": "hostname", + "title": "Host", + "description": "The host of the client", + "examples": [ + "10.1.1.1:9000" + ] + }, + "driver": { + "type": "string", + "enum": [ + "mysql", + "redis", + "memcache", + "kafka", + "mongo", + "postgres", + "zookeeper" + ], + "title": "Driver", + "description": "The driver of the client", + "examples": [ + "mysql" + ] + }, + "username": { + "type": "string", + "title": "Username", + "description": "The username of the client", + "examples": [ + "root" + ] + }, + "password": { + "type": "string", + "title": "Password", + "description": "The password of the client", + "examples": [ + "123456" + ] + }, + "data": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object", + "title": "Data", + "description": "The data of the client" + }, + "ca": { + "type": "string", + "title": "CA File", + "description": "the CA file path" + }, + "cert": { + "type": "string", + "title": "Cert File", + "description": "the Cert file path" + }, + "key": { + "type": "string", + "title": "Key File", + "description": "the Key file path" + }, + "insecure": { + "type": "boolean", + "title": "Insecure", + "description": "whether to skip the TLS verification" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "host", + "driver" + ] + }, + "probe_host_Host": { + "properties": { + "bastion": { + "$ref": "#/$defs/BastionMapType", + "title": "Bastion Servers", + "description": "the bastion server for ssh login" + }, + "servers": { + "items": { + "$ref": "#/$defs/probe_host_Server" + }, + "type": "array", + "title": "Host Servers", + "description": "the host servers to be monitored" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "servers" + ] + }, + "probe_host_Server": { + "properties": { + "name": { + "type": "string", + "title": "Probe Name", + "description": "the name of probe must be unique" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Probe Channels", + "description": "the channels of probe message need to send to" + }, + "timeout": { + "type": "string", + "title": "Probe Timeout", + "description": "the timeout of probe" + }, + "interval": { + "type": "string", + "title": "Probe Interval", + "description": "the interval of probe" + }, + "key": { + "type": "string", + "title": "Private Key", + "description": "the private key file path for ssh login" + }, + "passphrase": { + "type": "string", + "title": "Passphrase", + "description": "the passphrase for ssh private key" + }, + "host": { + "type": "string", + "format": "hostname", + "title": "Host", + "description": "the host for ssh probe" + }, + "username": { + "type": "string", + "title": "User", + "description": "the username for ssh probe" + }, + "password": { + "type": "string", + "title": "Password", + "description": "the password for ssh probe" + }, + "cmd": { + "type": "string", + "title": "Shell Command", + "description": "command to run" + }, + "args": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Shell Command Arguments", + "description": "arguments for the command" + }, + "env": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Environment Variables", + "description": "environment variables for the command" + }, + "contain": { + "type": "string", + "title": "Contain Text", + "description": "the string must be contained" + }, + "not_contain": { + "type": "string", + "title": "Not Contain Text", + "description": "the string must not be contained" + }, + "regex": { + "type": "boolean", + "title": "regex", + "description": "use regular expression to check the contain or not contain" + }, + "bastion": { + "type": "string", + "title": "Bastion Server", + "description": "the bastion host id" + }, + "threshold": { + "$ref": "#/$defs/probe_host_Threshold", + "title": "Threshold", + "description": "the threshold of the probe for cpu/memory/disk" + }, + "disks": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Disks", + "description": "the disks to be monitored" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "host" + ] + }, + "probe_host_Threshold": { + "properties": { + "cpu": { + "type": "number", + "title": "CPU threshold", + "description": "CPU threshold (default: 0.8)" + }, + "mem": { + "type": "number", + "title": "Memory threshold", + "description": "Memory threshold (default: 0.8)" + }, + "disk": { + "type": "number", + "title": "Disk threshold", + "description": "Disk threshold (default: 0.95)" + } + }, + "additionalProperties": false, + "type": "object" + }, + "probe_http_HTTP": { + "properties": { + "name": { + "type": "string", + "title": "Probe Name", + "description": "the name of probe must be unique" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Probe Channels", + "description": "the channels of probe message need to send to" + }, + "timeout": { + "type": "string", + "title": "Probe Timeout", + "description": "the timeout of probe" + }, + "interval": { + "type": "string", + "title": "Probe Interval", + "description": "the interval of probe" + }, + "url": { + "type": "string", + "format": "uri", + "title": "HTTP URL", + "description": "HTTP URL to probe" + }, + "proxy": { + "type": "string", + "title": "Proxy Server", + "description": "proxy to use for HTTP requests" + }, + "content_encoding": { + "type": "string", + "title": "Content Encoding", + "description": "content encoding to use for HTTP requests" + }, + "method": { + "type": "string", + "enum": [ + "GET", + "POST", + "DELETE", + "PUT", + "HEAD", + "OPTIONS", + "PATCH", + "TRACE", + "CONNECT" + ], + "title": "HTTP Method", + "description": "HTTP method to use for HTTP requests" + }, + "headers": { + "patternProperties": { + ".*": { + "type": "string" + } + }, + "type": "object", + "title": "HTTP Headers", + "description": "HTTP headers to use for HTTP requests" + }, + "body": { + "type": "string", + "title": "HTTP Body", + "description": "HTTP body to use for HTTP requests" + }, + "contain": { + "type": "string", + "title": "Contain Text", + "description": "the string must be contained" + }, + "not_contain": { + "type": "string", + "title": "Not Contain Text", + "description": "the string must not be contained" + }, + "regex": { + "type": "boolean", + "title": "regex", + "description": "use regular expression to check the contain or not contain" + }, + "eval": { + "$ref": "#/$defs/eval_Evaluator", + "title": "HTTP Evaluator", + "description": "HTTP evaluator to use for HTTP requests" + }, + "username": { + "type": "string", + "title": "HTTP Basic Auth Username", + "description": "HTTP Basic Auth Username" + }, + "password": { + "type": "string", + "title": "HTTP Basic Auth Password", + "description": "HTTP Basic Auth Password" + }, + "success_code": { + "items": { + "items": { + "type": "integer" + }, + "type": "array" + }, + "type": "array", + "title": "HTTP Success Code Range", + "description": "Preferred HTTP response code ranges. If not set the default is [0, 499]." + }, + "ca": { + "type": "string", + "title": "CA File", + "description": "the CA file path" + }, + "cert": { + "type": "string", + "title": "Cert File", + "description": "the Cert file path" + }, + "key": { + "type": "string", + "title": "Key File", + "description": "the Key file path" + }, + "insecure": { + "type": "boolean", + "title": "Insecure", + "description": "whether to skip the TLS verification" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "url" + ] + }, + "probe_shell_Shell": { + "properties": { + "name": { + "type": "string", + "title": "Probe Name", + "description": "the name of probe must be unique" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Probe Channels", + "description": "the channels of probe message need to send to" + }, + "timeout": { + "type": "string", + "title": "Probe Timeout", + "description": "the timeout of probe" + }, + "interval": { + "type": "string", + "title": "Probe Interval", + "description": "the interval of probe" + }, + "cmd": { + "type": "string", + "title": "Command Line", + "description": "Command Line" + }, + "args": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Command Line Arguments", + "description": "Command Line Arguments" + }, + "env": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Environment Variables", + "description": "Environment Variables" + }, + "clean_env": { + "type": "boolean", + "title": "Clean Environment", + "description": "set it to true to keep the environment variables of the current process" + }, + "contain": { + "type": "string", + "title": "Contain Text", + "description": "the string must be contained" + }, + "not_contain": { + "type": "string", + "title": "Not Contain Text", + "description": "the string must not be contained" + }, + "regex": { + "type": "boolean", + "title": "regex", + "description": "use regular expression to check the contain or not contain" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "cmd" + ] + }, + "probe_ssh_Endpoint": { + "properties": { + "key": { + "type": "string", + "title": "Private Key", + "description": "the private key file path for ssh login" + }, + "passphrase": { + "type": "string", + "title": "Passphrase", + "description": "the passphrase for ssh private key" + }, + "host": { + "type": "string", + "format": "hostname", + "title": "Host", + "description": "the host for ssh probe" + }, + "username": { + "type": "string", + "title": "User", + "description": "the username for ssh probe" + }, + "password": { + "type": "string", + "title": "Password", + "description": "the password for ssh probe" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "host" + ] + }, + "probe_ssh_SSH": { + "properties": { + "bastion": { + "$ref": "#/$defs/BastionMapType", + "title": "Bastion Servers", + "description": "the bastion hosts configuration" + }, + "servers": { + "items": { + "$ref": "#/$defs/probe_ssh_Server" + }, + "type": "array", + "title": "SSH Servers", + "description": "SSH servers to probe" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "servers" + ] + }, + "probe_ssh_Server": { + "properties": { + "name": { + "type": "string", + "title": "Probe Name", + "description": "the name of probe must be unique" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Probe Channels", + "description": "the channels of probe message need to send to" + }, + "timeout": { + "type": "string", + "title": "Probe Timeout", + "description": "the timeout of probe" + }, + "interval": { + "type": "string", + "title": "Probe Interval", + "description": "the interval of probe" + }, + "key": { + "type": "string", + "title": "Private Key", + "description": "the private key file path for ssh login" + }, + "passphrase": { + "type": "string", + "title": "Passphrase", + "description": "the passphrase for ssh private key" + }, + "host": { + "type": "string", + "format": "hostname", + "title": "Host", + "description": "the host for ssh probe" + }, + "username": { + "type": "string", + "title": "User", + "description": "the username for ssh probe" + }, + "password": { + "type": "string", + "title": "Password", + "description": "the password for ssh probe" + }, + "cmd": { + "type": "string", + "title": "Shell Command", + "description": "command to run" + }, + "args": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Shell Command Arguments", + "description": "arguments for the command" + }, + "env": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Environment Variables", + "description": "environment variables for the command" + }, + "contain": { + "type": "string", + "title": "Contain Text", + "description": "the string must be contained" + }, + "not_contain": { + "type": "string", + "title": "Not Contain Text", + "description": "the string must not be contained" + }, + "regex": { + "type": "boolean", + "title": "regex", + "description": "use regular expression to check the contain or not contain" + }, + "bastion": { + "type": "string", + "title": "Bastion Server", + "description": "the bastion host id" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "host" + ] + }, + "probe_tcp_TCP": { + "properties": { + "name": { + "type": "string", + "title": "Probe Name", + "description": "the name of probe must be unique" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Probe Channels", + "description": "the channels of probe message need to send to" + }, + "timeout": { + "type": "string", + "title": "Probe Timeout", + "description": "the timeout of probe" + }, + "interval": { + "type": "string", + "title": "Probe Interval", + "description": "the interval of probe" + }, + "host": { + "type": "string", + "format": "hostname", + "title": "Host", + "description": "The host to probe" + }, + "proxy": { + "type": "string", + "format": "hostname", + "title": "Proxy", + "description": "The proxy to use" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "host" + ] + }, + "probe_tls_TLS": { + "properties": { + "name": { + "type": "string", + "title": "Probe Name", + "description": "the name of probe must be unique" + }, + "channels": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Probe Channels", + "description": "the channels of probe message need to send to" + }, + "timeout": { + "type": "string", + "title": "Probe Timeout", + "description": "the timeout of probe" + }, + "interval": { + "type": "string", + "title": "Probe Interval", + "description": "the interval of probe" + }, + "host": { + "type": "string", + "format": "hostname", + "title": "Host", + "description": "The host to probe" + }, + "proxy": { + "type": "string", + "format": "hostname", + "title": "Proxy", + "description": "The proxy to use for the TLS connection" + }, + "insecure_skip_verify": { + "type": "boolean", + "title": "Insecure Skip Verify", + "description": "Whether to skip verifying the certificate chain and host name" + }, + "root_ca_pem_path": { + "type": "string", + "title": "Root CA PEM Path", + "description": "The path to the root CA PEM file" + }, + "root_ca_pem": { + "type": "string", + "title": "Root CA PEM", + "description": "The root CA PEM" + }, + "expire_skip_verify": { + "type": "boolean", + "title": "Expire Skip Verify", + "description": "Whether to skip verifying the certificate expire time" + }, + "alert_expire_before": { + "type": "integer", + "title": "Alert Expire Before", + "description": "The alert expire before time" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "host" + ] + } + } +}