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
7d205ae2
Commit
7d205ae2
authored
Feb 07, 2017
by
Carl Bergquist
Committed by
GitHub
Feb 07, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7466 from hagen1778/prometheus-basicauth-query
allow setting basic auth headers for prometheus datasource
parents
8ca4afaf
a1e83588
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
pkg/tsdb/prometheus/prometheus.go
+20
-0
No files found.
pkg/tsdb/prometheus/prometheus.go
View file @
7d205ae2
...
@@ -22,6 +22,18 @@ type PrometheusExecutor struct {
...
@@ -22,6 +22,18 @@ type PrometheusExecutor struct {
Transport
*
http
.
Transport
Transport
*
http
.
Transport
}
}
type
basicAuthTransport
struct
{
*
http
.
Transport
username
string
password
string
}
func
(
bat
basicAuthTransport
)
RoundTrip
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
req
.
SetBasicAuth
(
bat
.
username
,
bat
.
password
)
return
bat
.
Transport
.
RoundTrip
(
req
)
}
func
NewPrometheusExecutor
(
dsInfo
*
models
.
DataSource
)
(
tsdb
.
Executor
,
error
)
{
func
NewPrometheusExecutor
(
dsInfo
*
models
.
DataSource
)
(
tsdb
.
Executor
,
error
)
{
transport
,
err
:=
dsInfo
.
GetHttpTransport
()
transport
,
err
:=
dsInfo
.
GetHttpTransport
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -51,6 +63,14 @@ func (e *PrometheusExecutor) getClient() (prometheus.QueryAPI, error) {
...
@@ -51,6 +63,14 @@ func (e *PrometheusExecutor) getClient() (prometheus.QueryAPI, error) {
Transport
:
e
.
Transport
,
Transport
:
e
.
Transport
,
}
}
if
e
.
BasicAuth
{
cfg
.
Transport
=
basicAuthTransport
{
Transport
:
e
.
Transport
,
username
:
e
.
BasicAuthUser
,
password
:
e
.
BasicAuthPassword
,
}
}
client
,
err
:=
prometheus
.
New
(
cfg
)
client
,
err
:=
prometheus
.
New
(
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
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