Added support for Kusto (#3068)

This commit is contained in:
Michael Schmidt 2021-09-15 21:46:45 +02:00 committed by GitHub
parent 4433ccfc0c
commit e008ea056d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 555 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -731,6 +731,10 @@
"alias": "kum",
"owner": "edukisto"
},
"kusto": {
"title": "Kusto",
"owner": "RunDevelopment"
},
"latex": {
"title": "LaTeX",
"alias": ["tex", "context"],

44
components/prism-kusto.js Normal file
View File

@ -0,0 +1,44 @@
Prism.languages.kusto = {
'comment': {
pattern: /\/\/.*/,
greedy: true
},
'string': {
pattern: /```[\s\S]*?```|[hH]?(?:"(?:[^\r\n\\"]|\\.)*"|'(?:[^\r\n\\']|\\.)*'|@(?:"[^\r\n"]*"|'[^\r\n']*'))/,
greedy: true
},
'verb': {
pattern: /(\|\s*)[a-z][\w-]*/i,
lookbehind: true,
alias: 'keyword'
},
'command': {
pattern: /\.[a-z][a-z\d-]*\b/,
alias: 'keyword'
},
'class-name': /\b(?:bool|datetime|decimal|dynamic|guid|int|long|real|string|timespan)\b/,
'keyword': /\b(?:access|alias|and|anti|as|asc|auto|between|by|database|declare|desc|external|from|fullouter|has_all|in|ingestion|inline|inner|innerunique|into|let|like|local|not|of|on|or|pattern|print|query_parameters|range|restrict|schema|set|step|table|tables|to|view|where|with|(?:has(?:perfix|suffix)?|contains|(?:starts|ends)with)(?:_cs)?|(?:left|right)(?:anti(?:semi)?|inner|outer|semi)?|matches\s+regex|nulls\s+(?:first|last))(?![\w-])/,
'boolean': /\b(?:true|false|null)\b/,
'function': /\b[a-z_]\w*(?=\s*\()/,
'datetime': [
{
// RFC 822 + RFC 850
pattern: /\b(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\s*,\s*)?\d{1,2}(?:\s+|-)(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:\s+|-)\d{2}\s+\d{2}:\d{2}(?::\d{2})?(?:\s*(?:\b(?:(?:U|GM|[ECMT][DS])T|[A-Z])|[+-]\d{4}))?\b/,
alias: 'number'
},
{
// ISO 8601
pattern: /[+-]?\b(?:\d{4}-\d{2}-\d{2}(?:[ T]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)?|\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)Z?/,
alias: 'number'
}
],
'number': /\b(?:0x[0-9A-Fa-f]+|\d+(?:\.\d+)?(?:[Ee][+-]?\d+)?)(?:(?:min|sec|[mnµ]s|tick|microsecond|[dhms])\b)?|[+-]?\binf\b/,
'operator': /=>|[!=]~|[!=<>]=?|[-+*/%|]|\.\./,
'punctuation': /[()\[\]{},;.:]/
};

1
components/prism-kusto.min.js vendored Normal file
View File

@ -0,0 +1 @@
Prism.languages.kusto={comment:{pattern:/\/\/.*/,greedy:!0},string:{pattern:/```[\s\S]*?```|[hH]?(?:"(?:[^\r\n\\"]|\\.)*"|'(?:[^\r\n\\']|\\.)*'|@(?:"[^\r\n"]*"|'[^\r\n']*'))/,greedy:!0},verb:{pattern:/(\|\s*)[a-z][\w-]*/i,lookbehind:!0,alias:"keyword"},command:{pattern:/\.[a-z][a-z\d-]*\b/,alias:"keyword"},"class-name":/\b(?:bool|datetime|decimal|dynamic|guid|int|long|real|string|timespan)\b/,keyword:/\b(?:access|alias|and|anti|as|asc|auto|between|by|database|declare|desc|external|from|fullouter|has_all|in|ingestion|inline|inner|innerunique|into|let|like|local|not|of|on|or|pattern|print|query_parameters|range|restrict|schema|set|step|table|tables|to|view|where|with|(?:has(?:perfix|suffix)?|contains|(?:starts|ends)with)(?:_cs)?|(?:left|right)(?:anti(?:semi)?|inner|outer|semi)?|matches\s+regex|nulls\s+(?:first|last))(?![\w-])/,boolean:/\b(?:true|false|null)\b/,function:/\b[a-z_]\w*(?=\s*\()/,datetime:[{pattern:/\b(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\s*,\s*)?\d{1,2}(?:\s+|-)(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:\s+|-)\d{2}\s+\d{2}:\d{2}(?::\d{2})?(?:\s*(?:\b(?:(?:U|GM|[ECMT][DS])T|[A-Z])|[+-]\d{4}))?\b/,alias:"number"},{pattern:/[+-]?\b(?:\d{4}-\d{2}-\d{2}(?:[ T]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)?|\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)Z?/,alias:"number"}],number:/\b(?:0x[0-9A-Fa-f]+|\d+(?:\.\d+)?(?:[Ee][+-]?\d+)?)(?:(?:min|sec|[mnµ]s|tick|microsecond|[dhms])\b)?|[+-]?\binf\b/,operator:/=>|[!=]~|[!=<>]=?|[-+*/%|]|\.\./,punctuation:/[()\[\]{},;.:]/};

View File

@ -0,0 +1,8 @@
<h2>Full example</h2>
<pre><code>// Source: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/tutorial?pivots=azuredataexplorer
StormEvents
| where StartTime > datetime(2007-02-01) and StartTime &lt; datetime(2007-03-01)
| where EventType == 'Flood' and State == 'CALIFORNIA'
| project StartTime, EndTime , State , EventType , EpisodeNarrative
</code></pre>

View File

@ -0,0 +1,24 @@
true bool(true)
false bool(false)
bool(null)
----------------------------------------------------
[
["boolean", "true"],
["class-name", "bool"],
["punctuation", "("],
["boolean", "true"],
["punctuation", ")"],
["boolean", "false"],
["class-name", "bool"],
["punctuation", "("],
["boolean", "false"],
["punctuation", ")"],
["class-name", "bool"],
["punctuation", "("],
["boolean", "null"],
["punctuation", ")"]
]

View File

@ -0,0 +1,25 @@
bool
datetime
decimal
dynamic
guid
int
long
real
string
timespan
----------------------------------------------------
[
["class-name", "bool"],
["class-name", "datetime"],
["class-name", "decimal"],
["class-name", "dynamic"],
["class-name", "guid"],
["class-name", "int"],
["class-name", "long"],
["class-name", "real"],
["class-name", "string"],
["class-name", "timespan"]
]

View File

@ -0,0 +1,13 @@
.show tables
| count
.set foo=234
----------------------------------------------------
[
["command", ".show"], ["keyword", "tables"],
["operator", "|"], ["verb", "count"],
["command", ".set"], " foo", ["operator", "="], ["number", "234"]
]

View File

@ -0,0 +1,7 @@
// comment
----------------------------------------------------
[
["comment", "// comment"]
]

View File

@ -0,0 +1,61 @@
// ISO 8601
2014-05-25T08:20:03.123456Z
2014-05-25T08:20:03.123456
2014-05-25T08:20
2014-11-08 15:55:55.123456Z
2014-11-08 15:55:55
2014-11-08 15:55
2014-11-08
// RFC 822
Sat, 8 Nov 14 15:05:02 GMT
Sat, 8 Nov 14 15:05:02
Sat, 8 Nov 14 15:05
Sat, 8 Nov 14 15:05 GMT
8 Nov 14 15:05:02 GMT
8 Nov 14 15:05:02
8 Nov 14 15:05
8 Nov 14 15:05 GMT
// RFC 850
Saturday, 08-Nov-14 15:05:02 GMT
Saturday, 08-Nov-14 15:05:02
Saturday, 08-Nov-14 15:05 GMT
Saturday, 08-Nov-14 15:05
08-Nov-14 15:05:02 GMT
08-Nov-14 15:05:02
08-Nov-14 15:05 GMT
08-Nov-14 15:05
----------------------------------------------------
[
["comment", "// ISO 8601"],
["datetime", "2014-05-25T08:20:03.123456Z"],
["datetime", "2014-05-25T08:20:03.123456"],
["datetime", "2014-05-25T08:20"],
["datetime", "2014-11-08 15:55:55.123456Z"],
["datetime", "2014-11-08 15:55:55"],
["datetime", "2014-11-08 15:55"],
["datetime", "2014-11-08"],
["comment", "// RFC 822"],
["datetime", "Sat, 8 Nov 14 15:05:02 GMT"],
["datetime", "Sat, 8 Nov 14 15:05:02"],
["datetime", "Sat, 8 Nov 14 15:05"],
["datetime", "Sat, 8 Nov 14 15:05 GMT"],
["datetime", "8 Nov 14 15:05:02 GMT"],
["datetime", "8 Nov 14 15:05:02"],
["datetime", "8 Nov 14 15:05"],
["datetime", "8 Nov 14 15:05 GMT"],
["comment", "// RFC 850"],
["datetime", "Saturday, 08-Nov-14 15:05:02 GMT"],
["datetime", "Saturday, 08-Nov-14 15:05:02"],
["datetime", "Saturday, 08-Nov-14 15:05 GMT"],
["datetime", "Saturday, 08-Nov-14 15:05"],
["datetime", "08-Nov-14 15:05:02 GMT"],
["datetime", "08-Nov-14 15:05:02"],
["datetime", "08-Nov-14 15:05 GMT"],
["datetime", "08-Nov-14 15:05"]
]

View File

@ -0,0 +1,9 @@
min()
----------------------------------------------------
[
["function", "min"],
["punctuation", "("],
["punctuation", ")"]
]

View File

@ -0,0 +1,145 @@
access
alias
and
anti
as
asc
auto
between
by
contains
contains_cs
database
declare
desc
endswith
endswith_cs
external
from
fullouter
has
has_all
has_cs
hasperfix
hasperfix_cs
hassuffix
hassuffix_cs
in
ingestion
inline
inner
innerunique
into
left
leftanti
leftantisemi
leftinner
leftouter
leftsemi
let
like
local
matches regex
not
nulls first
nulls last
of
on
or
pattern
print
query_parameters
range
restrict
right
rightanti
rightantisemi
rightinner
rightouter
rightsemi
schema
set
startswith
startswith_cs
step
table
tables
to
view
where
with
----------------------------------------------------
[
["keyword", "access"],
["keyword", "alias"],
["keyword", "and"],
["keyword", "anti"],
["keyword", "as"],
["keyword", "asc"],
["keyword", "auto"],
["keyword", "between"],
["keyword", "by"],
["keyword", "contains"],
["keyword", "contains_cs"],
["keyword", "database"],
["keyword", "declare"],
["keyword", "desc"],
["keyword", "endswith"],
["keyword", "endswith_cs"],
["keyword", "external"],
["keyword", "from"],
["keyword", "fullouter"],
["keyword", "has"],
["keyword", "has_all"],
["keyword", "has_cs"],
["keyword", "hasperfix"],
["keyword", "hasperfix_cs"],
["keyword", "hassuffix"],
["keyword", "hassuffix_cs"],
["keyword", "in"],
["keyword", "ingestion"],
["keyword", "inline"],
["keyword", "inner"],
["keyword", "innerunique"],
["keyword", "into"],
["keyword", "left"],
["keyword", "leftanti"],
["keyword", "leftantisemi"],
["keyword", "leftinner"],
["keyword", "leftouter"],
["keyword", "leftsemi"],
["keyword", "let"],
["keyword", "like"],
["keyword", "local"],
["keyword", "matches regex"],
["keyword", "not"],
["keyword", "nulls first"],
["keyword", "nulls last"],
["keyword", "of"],
["keyword", "on"],
["keyword", "or"],
["keyword", "pattern"],
["keyword", "print"],
["keyword", "query_parameters"],
["keyword", "range"],
["keyword", "restrict"],
["keyword", "right"],
["keyword", "rightanti"],
["keyword", "rightantisemi"],
["keyword", "rightinner"],
["keyword", "rightouter"],
["keyword", "rightsemi"],
["keyword", "schema"],
["keyword", "set"],
["keyword", "startswith"],
["keyword", "startswith_cs"],
["keyword", "step"],
["keyword", "table"],
["keyword", "tables"],
["keyword", "to"],
["keyword", "view"],
["keyword", "where"],
["keyword", "with"]
]

View File

@ -0,0 +1,41 @@
0
123
123.456
123.456e-7
0xfF
+inf
-inf
// time
12d
12h
12m
12min
12s
12sec
12ms
----------------------------------------------------
[
["number", "0"],
["number", "123"],
["number", "123.456"],
["number", "123.456e-7"],
["number", "0xfF"],
["number", "+inf"],
["number", "-inf"],
["comment", "// time"],
["number", "12d"],
["number", "12h"],
["number", "12m"],
["number", "12min"],
["number", "12s"],
["number", "12sec"],
["number", "12ms"]
]

View File

@ -0,0 +1,33 @@
+ - * / %
== != < <= > >=
=~ !~
= !
=>
..
----------------------------------------------------
[
["operator", "+"],
["operator", "-"],
["operator", "*"],
["operator", "/"],
["operator", "%"],
["operator", "=="],
["operator", "!="],
["operator", "<"],
["operator", "<="],
["operator", ">"],
["operator", ">="],
["operator", "=~"],
["operator", "!~"],
["operator", "="],
["operator", "!"],
["operator", "=>"],
["operator", ".."]
]

View File

@ -0,0 +1,18 @@
( ) [ ] { }
, ; . :
----------------------------------------------------
[
["punctuation", "("],
["punctuation", ")"],
["punctuation", "["],
["punctuation", "]"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", ","],
["punctuation", ";"],
["punctuation", "."],
["punctuation", ":"]
]

View File

@ -0,0 +1,82 @@
""
''
@""
@''
"foo\""
'bar\''
@"\"
@'\'
```
multiline
```
// Obfuscated string literals
h'hello'
h@'world'
h"hello"
// string concatenation
print strlen("Hello"', '@"world!"); // Nothing between them
print strlen("Hello" ', ' @"world!"); // Separated by whitespace only
print strlen("Hello"
// Comment
', '@"world!"); // Separated by whitespace and a comment
----------------------------------------------------
[
["string", "\"\""],
["string", "''"],
["string", "@\"\""],
["string", "@''"],
["string", "\"foo\\\"\""],
["string", "'bar\\''"],
["string", "@\"\\\""],
["string", "@'\\'"],
["string", "```\r\nmultiline\r\n```"],
["comment", "// Obfuscated string literals"],
["string", "h'hello'"],
["string", "h@'world'"],
["string", "h\"hello\""],
["comment", "// string concatenation"],
["keyword", "print"],
["function", "strlen"],
["punctuation", "("],
["string", "\"Hello\""],
["string", "', '"],
["string", "@\"world!\""],
["punctuation", ")"],
["punctuation", ";"],
["comment", "// Nothing between them"],
["keyword", "print"],
["function", "strlen"],
["punctuation", "("],
["string", "\"Hello\""],
["string", "', '"],
["string", "@\"world!\""],
["punctuation", ")"],
["punctuation", ";"],
["comment", "// Separated by whitespace only"],
["keyword", "print"],
["function", "strlen"],
["punctuation", "("],
["string", "\"Hello\""],
["comment", "// Comment"],
["string", "', '"],
["string", "@\"world!\""],
["punctuation", ")"],
["punctuation", ";"],
["comment", "// Separated by whitespace and a comment"]
]

View File

@ -0,0 +1,39 @@
Logs
| where Timestamp > ago(1d)
| join
(
Events
| where continent == 'Europe'
) on RequestId
----------------------------------------------------
[
"Logs\r\n",
["operator", "|"],
["verb", "where"],
" Timestamp ",
["operator", ">"],
["function", "ago"],
["punctuation", "("],
["number", "1d"],
["punctuation", ")"],
["operator", "|"],
["verb", "join"],
["punctuation", "("],
"\r\n Events\r\n ",
["operator", "|"],
["verb", "where"],
" continent ",
["operator", "=="],
["string", "'Europe'"],
["punctuation", ")"],
["keyword", "on"],
" RequestId"
]