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
4a51d054
Commit
4a51d054
authored
Oct 10, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: add variable for gce authentication type
parent
b9cb4649
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
pkg/tsdb/stackdriver/stackdriver.go
+8
-7
No files found.
pkg/tsdb/stackdriver/stackdriver.go
View file @
4a51d054
...
...
@@ -31,9 +31,10 @@ import (
)
var
(
slog
log
.
Logger
legendKeyFormat
*
regexp
.
Regexp
metricNameFormat
*
regexp
.
Regexp
slog
log
.
Logger
legendKeyFormat
*
regexp
.
Regexp
metricNameFormat
*
regexp
.
Regexp
gceAuthentication
string
)
// StackdriverExecutor executes queries for the Stackdriver datasource
...
...
@@ -60,6 +61,7 @@ func init() {
tsdb
.
RegisterTsdbQueryEndpoint
(
"stackdriver"
,
NewStackdriverExecutor
)
legendKeyFormat
=
regexp
.
MustCompile
(
`\{\{\s*(.+?)\s*\}\}`
)
metricNameFormat
=
regexp
.
MustCompile
(
`([\w\d_]+)\.googleapis\.com/(.+)`
)
gceAuthentication
=
"gce"
}
// Query takes in the frontend queries, parses them into the Stackdriver query format
...
...
@@ -92,7 +94,7 @@ func (e *StackdriverExecutor) executeTimeSeriesQuery(ctx context.Context, tsdbQu
}
authenticationType
:=
e
.
dsInfo
.
JsonData
.
Get
(
"authenticationType"
)
.
MustString
(
"jwt"
)
if
authenticationType
==
"gce"
{
if
authenticationType
==
gceAuthentication
{
defaultProject
,
err
:=
e
.
getDefaultProject
(
ctx
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to retrieve default project from GCE metadata server. error: %v"
,
err
)
...
...
@@ -585,11 +587,10 @@ func (e *StackdriverExecutor) createRequest(ctx context.Context, dsInfo *models.
func
(
e
*
StackdriverExecutor
)
getDefaultProject
(
ctx
context
.
Context
)
(
string
,
error
)
{
authenticationType
:=
e
.
dsInfo
.
JsonData
.
Get
(
"authenticationType"
)
.
MustString
(
"jwt"
)
if
authenticationType
==
"gce"
{
if
authenticationType
==
gceAuthentication
{
defaultCredentials
,
err
:=
google
.
FindDefaultCredentials
(
ctx
,
"https://www.googleapis.com/auth/monitoring.read"
)
if
err
!=
nil
{
return
"raintank-production"
,
nil
// return "", fmt.Errorf("Failed to retrieve default project from GCE metadata server. error: %v", err)
return
""
,
fmt
.
Errorf
(
"Failed to retrieve default project from GCE metadata server. error: %v"
,
err
)
}
else
{
logger
.
Info
(
"projectName"
,
"projectName"
,
defaultCredentials
.
ProjectID
)
return
defaultCredentials
.
ProjectID
,
nil
...
...
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