Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImgUploader: add support for non-amazon S3 #20354

Merged
merged 7 commits into from Jan 2, 2020

Conversation

emmericp
Copy link
Contributor

@emmericp emmericp commented Nov 13, 2019

Make hostname for S3 upload configurable to support non-Amazon S3 backends. Also add an option to use path style access as some poorly configured S3 backends sometimes don't support the default subdomain mode.

Fixes #8157

Question: how is the S3 backend usually tested? I found an integration test but no information on how it is usually run?

@marefr marefr added area/backend pr/external This PR is from external contributor labels Nov 13, 2019
@marefr
Copy link
Member

marefr commented Nov 13, 2019

@emmericp Thanks. The issue you're referring to is closed. However, there's another one #8157. Please update PR description if you think your PR solves this feature request taking this #8157 (comment) into account.

@emmericp
Copy link
Contributor Author

Oh, I didn't see that one. Yeah, it should work with virtually anything that implements the bare minimum of S3 because it doesn't use any advanced feature at all. I've only tested it against Ceph/radosgw which implements most S3 and most S3-compatible services you find on the Internet run it.

Updated

@stale
Copy link

stale bot commented Dec 2, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale Issue with no recent activity label Dec 2, 2019
@emmericp
Copy link
Contributor Author

emmericp commented Dec 2, 2019

ping

@stale stale bot removed the stale Issue with no recent activity label Dec 2, 2019
@stale
Copy link

stale bot commented Dec 16, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale Issue with no recent activity label Dec 16, 2019
@emmericp
Copy link
Contributor Author

ping. happy to provide test access to a public S3 bucket

@stale stale bot removed the stale Issue with no recent activity label Dec 16, 2019
@marefr
Copy link
Member

marefr commented Dec 16, 2019

We're planning to review this soon. Please have patient. Thanks

@marefr marefr requested review from a team, kylebrandt, marcusolsson and aknuds1 and removed request for a team, kylebrandt and marcusolsson December 17, 2019 10:37
@aknuds1 aknuds1 self-assigned this Dec 17, 2019
@stale
Copy link

stale bot commented Dec 31, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale Issue with no recent activity label Dec 31, 2019
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@stale stale bot removed the stale Issue with no recent activity label Jan 2, 2020
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@aknuds1 aknuds1 moved this from To do to Under review in Backend Platform Squad Jan 2, 2020
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Copy link
Contributor

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Please note though that I renamed the 'host' setting to 'endpoint', in order to be consistent with S3 nomenclature.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@aknuds1 aknuds1 merged commit 42032f6 into grafana:master Jan 2, 2020
Backend Platform Squad automation moved this from Under review to Done Jan 2, 2020
@aknuds1
Copy link
Contributor

aknuds1 commented Jan 2, 2020

Merged - thanks for contributing to Grafana!

johntdyer pushed a commit to johntdyer/grafana that referenced this pull request Jan 2, 2020
* imguploader: add support for non-Amazon S3 endpoints and forcing of path-style S3 addressing

fixes grafana#11240

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
@marefr marefr added this to the 6.6.0-beta1 milestone Jan 28, 2020
@IamAliBaba
Copy link

Hello,
We are testing Ceph S3 capability with Grafana seems not working or no clean documentation.

"Failed to render and upload alert panel image." logger=alerting.notifier ruleId=7 error="Could not find bucket setting for image.uploader.s3"

Here is my config.

[external_image_storage.s3]
endpoint = s3.xxx.com
;path_style_access = https://s3.xxxx.com/BUCKET/
;bucket = xx-grafana-bucket
;region = us-east-1
;path =
bucket_url = https://s3.xxxx.com/xx-grafana-bucket
access_key = xxx
secret_key = xxx

Can you please give a more config info.

Thanks.

@IamAliBaba
Copy link

bellow info show that S3 works from that server .

root@dash:~# s3cmd --configure

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
Access Key [xxxxxx]:
Secret Key [xxxxx]:
Default Region [us]: us

Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [s3.xxxxx.com]:

Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [s3.xxxxx.com/(bucket)s]:

Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:
Path to GPG program [/usr/bin/gpg]:

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [Yes]:

On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't connect to S3 directly
HTTP Proxy server name:

New settings:
Access Key: xxxxx
Secret Key: xxxxx
Default Region: us
S3 Endpoint: s3.xxxxx.com
DNS-style bucket+hostname:port template for accessing a bucket: s3.xxxx.com/(bucket)s
Encryption password:
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: True
HTTP Proxy server name:
HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n] y
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)

Now verifying that encryption works...
Not configured. Never mind.

@@ -35,7 +35,7 @@ func NewImageUploader() (ImageUploader, error) {
return nil, err
}

host := s3sec.Key("host").MustString("")
endpoint := s3sec.Key("endpoint").MustString("")
pathStyleAccess := s3sec.Key("path_style_access").MustBool(false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not working line.

@IamAliBaba
Copy link

Hi ,
We have non-AWS S3 and having issue with ImageUploader .

our S3 path_style_access is https://s3.xxxxxxx.com/bucket/key not https://bucket.s3.xxxxxxx.com/key .

I have this configuration on grafana.ini

[external_image_storage.s3]
endpoint = https://s3.XXXXXX.com
path_style_access = https://s3.XXXXX.com/BUCKET/KEY
bucket = XX-grafana-bucket
region = us
;path =
access_key = XXXXX
secret_key = XXXXX

i changed path_style_access to our custom but it still trying to connect to this one ` https://bucket.s3.xxxxxxx.com/key

LOG:

t=2020-12-09T07:16:37-0500 lvl=eror msg="Failed to render and upload alert panel image." logger=alerting.notifier ruleId=7 error="RequestError: send request failed\ncaused by: Put "**https://xxx-grafana-bucket.s3.xxxxxx.com/gSvYnzqm8MDUnpMyIk7X.png**\": x509: certificate is valid for *.xxxxxxxx.com, xxxxxxxx.com, not xx-grafana-bucket.s3.xxxxxxx.com"

Seems BUG.

@oddlittlebird
Copy link
Contributor

oddlittlebird commented Dec 9, 2020

Hi @IamAliBaba! I'm sorry you are having trouble with this. Please file a bug report.

@grafana grafana locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/backend pr/external This PR is from external contributor
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

[Feature Request] Allow to use S3 compatible services
5 participants