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
50d82155
Commit
50d82155
authored
Sep 27, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/williamjoy/grafana
into williamjoy-master
parents
2ed75323
88a89917
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
14 deletions
+24
-14
conf/defaults.ini
+2
-1
conf/sample.ini
+2
-1
docs/sources/installation/configuration.md
+5
-1
pkg/components/imguploader/imguploader.go
+10
-4
pkg/components/imguploader/s3uploader.go
+5
-7
No files found.
conf/defaults.ini
View file @
50d82155
...
...
@@ -476,7 +476,8 @@ sampler_param = 1
provider
=
[external_image_storage.s3]
bucket_url
=
bucket
=
region
=
access_key
=
secret_key
=
...
...
conf/sample.ini
View file @
50d82155
...
...
@@ -422,7 +422,8 @@
;provider =
[external_image_storage.s3]
;bucket_url =
;bucket =
;region =
;access_key =
;secret_key =
...
...
docs/sources/installation/configuration.md
View file @
50d82155
...
...
@@ -651,12 +651,16 @@ These options control how images should be made public so they can be shared on
You can choose between (s3, webdav, gcs). If left empty Grafana will ignore the upload action.
## [external_image_storage.s3]
### bucket
Bucket name for S3. e.g. grafana.snapshot
### region
Region name for S3. e.g. 'us-east-1', 'cn-north-1', etc
### bucket_url
(for backward compatibility, only works when no bucket or region are configured)
Bucket URL for S3. AWS region can be specified within URL or defaults to 'us-east-1', e.g.
-
http://grafana.s3.amazonaws.com/
-
https://grafana.s3-ap-southeast-2.amazonaws.com/
-
https://grafana.s3-cn-north-1.amazonaws.com.cn
### access_key
Access key. e.g. AAAAAAAAAAAAAAAAAAAA
...
...
pkg/components/imguploader/imguploader.go
View file @
50d82155
...
...
@@ -28,15 +28,21 @@ func NewImageUploader() (ImageUploader, error) {
return
nil
,
err
}
bucket
:=
s3sec
.
Key
(
"bucket"
)
.
MustString
(
""
)
region
:=
s3sec
.
Key
(
"region"
)
.
MustString
(
""
)
bucketUrl
:=
s3sec
.
Key
(
"bucket_url"
)
.
MustString
(
""
)
accessKey
:=
s3sec
.
Key
(
"access_key"
)
.
MustString
(
""
)
secretKey
:=
s3sec
.
Key
(
"secret_key"
)
.
MustString
(
""
)
info
,
err
:=
getRegionAndBucketFromUrl
(
bucketUrl
)
if
err
!=
nil
{
return
nil
,
err
if
bucket
==
""
||
region
==
""
{
info
,
err
:=
getRegionAndBucketFromUrl
(
bucketUrl
)
if
err
!=
nil
{
return
nil
,
err
}
bucket
=
info
.
bucket
region
=
info
.
region
}
return
NewS3Uploader
(
info
.
region
,
info
.
bucket
,
"public-read"
,
accessKey
,
secretKey
),
nil
return
NewS3Uploader
(
region
,
bucket
,
"public-read"
,
accessKey
,
secretKey
),
nil
case
"webdav"
:
webdavSec
,
err
:=
setting
.
Cfg
.
GetSection
(
"external_image_storage.webdav"
)
if
err
!=
nil
{
...
...
pkg/components/imguploader/s3uploader.go
View file @
50d82155
...
...
@@ -9,6 +9,7 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/grafana/grafana/pkg/log"
...
...
@@ -54,8 +55,10 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
Credentials
:
creds
,
}
s3_endpoint
,
_
:=
endpoints
.
DefaultResolver
()
.
EndpointFor
(
"s3"
,
u
.
region
)
key
:=
util
.
GetRandomString
(
20
)
+
".png"
log
.
Debug
(
"Uploading image to s3"
,
"bucket = "
,
u
.
bucket
,
", key = "
,
key
)
image_url
:=
s3_endpoint
.
URL
+
"/"
+
u
.
bucket
+
"/"
+
key
log
.
Debug
(
"Uploading image to s3"
,
"url = "
,
image_url
)
file
,
err
:=
os
.
Open
(
imageDiskPath
)
if
err
!=
nil
{
...
...
@@ -78,10 +81,5 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
if
err
!=
nil
{
return
""
,
err
}
if
u
.
region
==
"us-east-1"
{
return
"https://"
+
u
.
bucket
+
".s3.amazonaws.com/"
+
key
,
nil
}
else
{
return
"https://"
+
u
.
bucket
+
".s3-"
+
u
.
region
+
".amazonaws.com/"
+
key
,
nil
}
return
image_url
,
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