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
76c9f622
Commit
76c9f622
authored
Jan 16, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Ricky-N-feature/dataProxyAuditLog'
parents
873a8bc5
06440ef5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
0 deletions
+56
-0
conf/defaults.ini
+6
-0
conf/sample.ini
+10
-0
docs/sources/http_api/admin.md
+1
-0
pkg/api/dataproxy.go
+33
-0
pkg/setting/setting.go
+6
-0
No files found.
conf/defaults.ini
View file @
76c9f622
...
...
@@ -113,6 +113,12 @@ cookie_secure = false
session_life_time
=
86400
gc_interval_time
=
86400
#################################### Data proxy ###########################
[dataproxy]
# This enables data proxy logging, default is false
logging
=
false
#################################### Analytics ###########################
[analytics]
# Server reporting, sends usage counters to stats.grafana.org every 24 hours.
...
...
conf/sample.ini
View file @
76c9f622
...
...
@@ -49,6 +49,9 @@
# Log web requests
;router_logging = false
# This enables query request audit logging, output at warn level, default is false
;data_proxy_logging = false
# the path relative working path
;static_root_path = public
...
...
@@ -104,6 +107,13 @@
# Session life time, default is 86400
;session_life_time = 86400
#################################### Data proxy ###########################
[dataproxy]
# This enables data proxy logging, default is false
;logging = false
#################################### Analytics ####################################
[analytics]
# Server reporting, sends usage counters to stats.grafana.org every 24 hours.
...
...
docs/sources/http_api/admin.md
View file @
76c9f622
...
...
@@ -143,6 +143,7 @@ with Grafana admin permission.
"protocol":"http",
"root_url":"%(protocol)s://%(domain)s:%(http_port)s/",
"router_logging":"true",
"data_proxy_logging":"true",
"static_root_path":"public"
},
"session":{
...
...
pkg/api/dataproxy.go
View file @
76c9f622
package
api
import
(
"bytes"
"io/ioutil"
"net/http"
"net/http/httputil"
"net/url"
...
...
@@ -8,6 +10,7 @@ import (
"github.com/grafana/grafana/pkg/api/cloudwatch"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/middleware"
m
"github.com/grafana/grafana/pkg/models"
...
...
@@ -15,6 +18,10 @@ import (
"github.com/grafana/grafana/pkg/util"
)
var
(
dataproxyLogger
log
.
Logger
=
log
.
New
(
"data-proxy-log"
)
)
func
NewReverseProxy
(
ds
*
m
.
DataSource
,
proxyPath
string
,
targetUrl
*
url
.
URL
)
*
httputil
.
ReverseProxy
{
director
:=
func
(
req
*
http
.
Request
)
{
req
.
URL
.
Scheme
=
targetUrl
.
Scheme
...
...
@@ -121,6 +128,32 @@ func ProxyDataSourceRequest(c *middleware.Context) {
c
.
JsonApiErr
(
400
,
"Unable to load TLS certificate"
,
err
)
return
}
logProxyRequest
(
ds
.
Type
,
c
)
proxy
.
ServeHTTP
(
c
.
Resp
,
c
.
Req
.
Request
)
c
.
Resp
.
Header
()
.
Del
(
"Set-Cookie"
)
}
func
logProxyRequest
(
dataSourceType
string
,
c
*
middleware
.
Context
)
{
if
!
setting
.
DataProxyLogging
{
return
}
var
body
string
if
c
.
Req
.
Request
.
Body
!=
nil
{
buffer
,
err
:=
ioutil
.
ReadAll
(
c
.
Req
.
Request
.
Body
)
if
err
==
nil
{
c
.
Req
.
Request
.
Body
=
ioutil
.
NopCloser
(
bytes
.
NewBuffer
(
buffer
))
body
=
string
(
buffer
)
}
}
dataproxyLogger
.
Info
(
"Proxying incoming request"
,
"userid"
,
c
.
UserId
,
"orgid"
,
c
.
OrgId
,
"username"
,
c
.
Login
,
"datasource"
,
dataSourceType
,
"uri"
,
c
.
Req
.
RequestURI
,
"method"
,
c
.
Req
.
Request
.
Method
,
"body"
,
body
)
}
pkg/setting/setting.go
View file @
76c9f622
...
...
@@ -66,6 +66,7 @@ var (
SshPort
int
CertFile
,
KeyFile
string
RouterLogging
bool
DataProxyLogging
bool
StaticRootPath
string
EnableGzip
bool
EnforceDomain
bool
...
...
@@ -491,6 +492,7 @@ func NewConfigContext(args *CommandLineArgs) error {
HttpAddr
=
server
.
Key
(
"http_addr"
)
.
MustString
(
DEFAULT_HTTP_ADDR
)
HttpPort
=
server
.
Key
(
"http_port"
)
.
MustString
(
"3000"
)
RouterLogging
=
server
.
Key
(
"router_logging"
)
.
MustBool
(
false
)
EnableGzip
=
server
.
Key
(
"enable_gzip"
)
.
MustBool
(
false
)
EnforceDomain
=
server
.
Key
(
"enforce_domain"
)
.
MustBool
(
false
)
StaticRootPath
=
makeAbsolute
(
server
.
Key
(
"static_root_path"
)
.
String
(),
HomePath
)
...
...
@@ -499,6 +501,10 @@ func NewConfigContext(args *CommandLineArgs) error {
return
err
}
// read data proxy settings
dataproxy
:=
Cfg
.
Section
(
"dataproxy"
)
DataProxyLogging
=
dataproxy
.
Key
(
"logging"
)
.
MustBool
(
false
)
// read security settings
security
:=
Cfg
.
Section
(
"security"
)
SecretKey
=
security
.
Key
(
"secret_key"
)
.
String
()
...
...
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