Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
e98254e1
Commit
e98254e1
authored
Sep 07, 2017
by
Mitsuhiro Tanda
Committed by
Torkel Ödegaard
Sep 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show only label name in label matcher (#9167)
parent
4446e951
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
public/app/core/components/code_editor/mode-prometheus.js
+34
-2
public/app/plugins/datasource/prometheus/completer.ts
+18
-0
No files found.
public/app/core/components/code_editor/mode-prometheus.js
View file @
e98254e1
...
...
@@ -49,15 +49,42 @@ var PrometheusHighlightRules = function() {
regex
:
"
\\
+|
\\
-|
\\
*|
\\
/|%|
\\
^|=|==|!=|<=|>=|<|>|=
\\
~|!
\\
~"
},
{
token
:
"paren.lparen"
,
regex
:
"[[({]"
regex
:
"[[(]"
},
{
token
:
"paren.lparen"
,
regex
:
"{"
,
next
:
"start-label-matcher"
},
{
token
:
"paren.rparen"
,
regex
:
"[
\\
])]"
},
{
token
:
"paren.rparen"
,
regex
:
"
[
\\
])}]
"
regex
:
"
}
"
},
{
token
:
"text"
,
regex
:
"
\\
s+"
}
],
"start-label-matcher"
:
[
{
token
:
"label.name"
,
regex
:
'[a-zA-Z_][a-zA-Z0-9_]*'
},
{
token
:
"label.matching_operator"
,
regex
:
'=|!=|=~|!~'
},
{
token
:
"label.value"
,
regex
:
'"[^"]*"|
\'
[^
\'
]*
\'
'
},
{
token
:
"label.matching_delimiter"
,
regex
:
","
,
push
:
'start-label-matcher'
},
{
token
:
"label.matching_end"
,
regex
:
"}"
,
next
:
"start"
}
]
};
this
.
normalizeRules
();
};
oop
.
inherits
(
PrometheusHighlightRules
,
TextHighlightRules
);
...
...
@@ -373,6 +400,11 @@ var PrometheusCompletions = function() {};
(
function
()
{
this
.
getCompletions
=
function
(
state
,
session
,
pos
,
prefix
,
callback
)
{
let
token
=
session
.
getTokenAt
(
pos
.
row
,
pos
.
column
);
if
(
token
.
type
===
'label.name'
||
token
.
type
===
'label.value'
)
{
return
callback
(
null
,
[]);
}
var
completions
=
keyWordsCompletions
.
concat
(
functionsCompletions
);
callback
(
null
,
completions
);
};
...
...
public/app/plugins/datasource/prometheus/completer.ts
View file @
e98254e1
...
...
@@ -9,6 +9,24 @@ export class PromCompleter {
}
getCompletions
(
editor
,
session
,
pos
,
prefix
,
callback
)
{
let
token
=
session
.
getTokenAt
(
pos
.
row
,
pos
.
column
);
switch
(
token
.
type
)
{
case
'label.name'
:
callback
(
null
,
[
'instance'
,
'job'
].
map
(
function
(
key
)
{
return
{
caption
:
key
,
value
:
key
,
meta
:
"label name"
,
score
:
Number
.
MAX_VALUE
};
}));
return
;
case
'label.value'
:
callback
(
null
,
[]);
return
;
}
if
(
prefix
===
'['
)
{
var
vectors
=
[];
for
(
let
unit
of
[
's'
,
'm'
,
'h'
])
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment