Code Monkey home page Code Monkey logo

elastic-monitor-config's Introduction

Elastic Beats

Yaml Validation in VS Code

Chron Syntax / Regex

cron cronexpr cron editor

Create a regular expression for Cron statement

General Format

Field name Mandatory? Allowed values Special characters
Seconds No* 0-59 * / , -
Minutes Yes 0-59 * / , -
Hours Yes 0-23 * / , -
Day of month Yes 1-31 * / , - L W
Month Yes 1-12 or JAN-DEC * / , -
Day of week Yes 0-6 or SUN-SAT * / , - L #
Year No* 1970–2099 * / , -

Predefined Scheduling Macros:

Entry Equivalent to
@annually 0 0 0 1 1 * *
@yearly 0 0 0 1 1 * *
@monthly 0 0 0 1 * * *
@weekly 0 0 0 * * 0 *
@daily 0 0 0 * * * *
@hourly 0 0 * * * * *
@reboot

Valid time units:

unit definition
ns nanosecond
us, µs microsecond
ms millisecond
s second
m minute
h hour

Regex to allow only number between 1 to 12

Allowed values Regex
0-59 [1-5]?[0-9]
0-23 2[0-3]|1[0-9]|[0-9]
1-31 3[01]|[12][0-9]|[1-9]
1-12 1[0-2]|[1-9]
0-6 [0-6]
1970–2099 19[7-9][0-9]|20[0-9][0-9]

JSON Schema Definition

Mapping to a schema defined in settings

"json.schemas": [
    {
        "fileMatch": [
            "monitors.d/*.json"
        ],
        "url": "./heartbeat-schema.json"
    }
]

Structuring a complex schema

{ "$ref": "definitions.json#/address" }

JsonSchema - conditionally require attribute

Applying subschemas conditionally

"anyOf": [
  {
    "properties": { "type": { "const": "icmp" } },
    "required": ["hosts"]
  },
  {
    "properties": {
      "controlType": {"const": "title"}
    },
    "required": ["controlType"]
  },
  {
    "properties": {
      "controlType": {"const": "button"}
    },
    "required": ["controlType"]
  }
],
"allOf": [
  {
    "if": {
      "properties": { "type": { "const": "icmp" } }
    },
    "then": {
      "properties": {
        "hosts": {"$ref": "#/definitions/hosts"},
        "wait": {"$ref": "#/definitions/wait"}
      }
    }
  },
  {
    "if": {
      "properties": { "type": { "const": "tcp" } }
    },
    "then": {
      "properties": {
          "postal_code": { "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" }
      }
    }
  },
  {
    "if": {
      "properties": { "type": { "const": "http" } }
    },
    "then": {
      "properties": {
          "postal_code": { "pattern": "[0-9]{4} [A-Z]{2}" } 
      }
    }
  }
],
"oneOf": [

  { 
    "properties": {
      "type": { "const": "icmp" },
      "hosts": {"$ref": "#/definitions/hosts"},
      "wait": {"$ref": "#/definitions/wait"}
    }
  },
  { 
    "properties": {
      "type": { "const": "tcp" },
      "hosts": {"$ref": "#/definitions/hosts"}
    }
  },
  { 
    "properties": {
      "type": { "const": "http" },
      "urls": {"$ref": "#/definitions/urls"}
    }
  }
],

URL Validaiton / Format

{
    "type": "string",
    "format": "uri",
    "pattern": "^(https?|wss?|ftp)://"
}

JsonSchema - Array

{
    "type": "array",
    "items": {
        "type": "string"
    }
}

JsonSchema - String

{ "type": "string" }

Using RegEx in JSON Schema

"phone": {
    "type": "string",
    "pattern": "^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$"
}

Annotate Enum Values with description

Instead of:

"enum": ["foo", "bar", "whatever"]

Do This:

"oneOf": [
    {"const": "foo", "title": "Pick Foo"},
    {"const": "bar", "title": "Pick Bar"},
    {"const": "whatever", "title": "Don't Care"}
]

Make sure item property in array is unique in Json Schema?

Nope

elastic-monitor-config's People

Contributors

kylemit avatar

Watchers

James Cloos avatar  avatar Mud Punk avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.