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
df215d9d
Commit
df215d9d
authored
Oct 03, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: WIP - test retrieving project id from gce metadata
parent
fbe0ffd1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
pkg/api/pluginproxy/ds_auth_provider.go
+24
-2
pkg/tsdb/stackdriver/stackdriver.go
+3
-0
No files found.
pkg/api/pluginproxy/ds_auth_provider.go
View file @
df215d9d
...
@@ -64,11 +64,33 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
...
@@ -64,11 +64,33 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
}
}
if
req
.
Header
.
Get
(
"Authorization"
)
==
""
&&
ds
.
Type
==
"stackdriver"
{
if
req
.
Header
.
Get
(
"Authorization"
)
==
""
&&
ds
.
Type
==
"stackdriver"
{
tokenSrc
,
err
:=
google
.
DefaultTokenSource
(
ctx
,
"https://www.googleapis.com/auth/monitoring.read"
)
defaultCredentials
,
err
:=
google
.
FindDefaultCredentials
(
ctx
)
projectName
:=
ds
.
JsonData
.
Get
(
"defaultProject"
)
.
MustString
()
if
projectName
==
""
{
ds
.
JsonData
.
Set
(
"defaultProject"
,
defaultCredentials
.
ProjectID
)
}
if
err
!=
nil
{
logger
.
Error
(
"Failed to get default credentials"
,
"error"
,
err
)
}
else
{
token
,
err
:=
defaultCredentials
.
TokenSource
.
Token
()
if
err
!=
nil
{
logger
.
Error
(
"Failed to get default access token"
,
"error"
,
err
)
}
else
{
req
.
Header
.
Add
(
"Authorization"
,
fmt
.
Sprintf
(
"Bearer %s"
,
token
.
AccessToken
))
}
}
}
if
req
.
Header
.
Get
(
"Authorization"
)
==
""
&&
ds
.
Type
==
"stackdriver"
{
credentials
,
err
:=
google
.
FindDefaultCredentials
(
ctx
,
"https://www.googleapis.com/auth/monitoring.read"
)
projectName
:=
ds
.
JsonData
.
Get
(
"defaultProject"
)
.
MustString
()
if
projectName
==
""
{
ds
.
JsonData
.
Set
(
"defaultProject"
,
credentials
.
ProjectID
)
}
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"Failed to get access token"
,
"error"
,
err
)
logger
.
Error
(
"Failed to get access token"
,
"error"
,
err
)
}
else
{
}
else
{
token
,
err
:=
tokenSrc
.
Token
()
token
,
err
:=
credentials
.
TokenSource
.
Token
()
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"Failed to get access token"
,
"error"
,
err
)
logger
.
Error
(
"Failed to get access token"
,
"error"
,
err
)
}
else
{
}
else
{
...
...
pkg/tsdb/stackdriver/stackdriver.go
View file @
df215d9d
...
@@ -15,6 +15,8 @@ import (
...
@@ -15,6 +15,8 @@ import (
"strings"
"strings"
"time"
"time"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
"golang.org/x/net/context/ctxhttp"
"golang.org/x/net/context/ctxhttp"
"github.com/grafana/grafana/pkg/api/pluginproxy"
"github.com/grafana/grafana/pkg/api/pluginproxy"
...
@@ -551,6 +553,7 @@ func (e *StackdriverExecutor) createRequest(ctx context.Context, dsInfo *models.
...
@@ -551,6 +553,7 @@ func (e *StackdriverExecutor) createRequest(ctx context.Context, dsInfo *models.
return
nil
,
errors
.
New
(
"Unable to find datasource plugin Stackdriver"
)
return
nil
,
errors
.
New
(
"Unable to find datasource plugin Stackdriver"
)
}
}
projectName
:=
dsInfo
.
JsonData
.
Get
(
"defaultProject"
)
.
MustString
()
projectName
:=
dsInfo
.
JsonData
.
Get
(
"defaultProject"
)
.
MustString
()
logger
.
Info
(
"projectName"
,
"projectName"
,
projectName
)
proxyPass
:=
fmt
.
Sprintf
(
"stackdriver%s"
,
"v3/projects/"
+
projectName
+
"/timeSeries"
)
proxyPass
:=
fmt
.
Sprintf
(
"stackdriver%s"
,
"v3/projects/"
+
projectName
+
"/timeSeries"
)
var
stackdriverRoute
*
plugins
.
AppPluginRoute
var
stackdriverRoute
*
plugins
.
AppPluginRoute
...
...
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