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

fix: tiup supports define root_url and enable anonymous in grafana.ini #1085

Merged
merged 3 commits into from
Jan 25, 2021

Conversation

mianhk
Copy link
Contributor

@mianhk mianhk commented Jan 21, 2021

What problem does this PR solve?

fix: #849

What is changed and how it works?

  1. You can configure Grafana to run behind a reverse proxy.
    reference: https://grafana.com/tutorials/run-grafana-behind-a-proxy/#1
  2. You can set grafana access anonymous

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
tiup cluster edit-config test_cluster

support config:
- host: 127.0.0.2
  ssh_port: 22
  arch: amd64
  os: linux
  username: admin
  password: admin
  anonymous_enable: true
  root_url: /tidb/grafana/test-cluster
  domain: example.com

Then, you can get a grafana.ini like:

[auth.anonymous]
enabled = true
# The full public facing url
[server]
domain = example.com
...
root_url = /tidb/grafana/test-cluster
server_from_sub_path = true
  • No code

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release notes:

NONE

@CLAassistant
Copy link

CLAassistant commented Jan 21, 2021

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 21, 2021
@codecov-io
Copy link

codecov-io commented Jan 21, 2021

Codecov Report

Merging #1085 (8b111b1) into master (09833d6) will decrease coverage by 1.14%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1085      +/-   ##
==========================================
- Coverage   56.56%   55.42%   -1.15%     
==========================================
  Files         283      283              
  Lines       20016    20025       +9     
==========================================
- Hits        11323    11098     -225     
- Misses       6937     7207     +270     
+ Partials     1756     1720      -36     
Flag Coverage Δ
cluster 42.66% <100.00%> (-2.44%) ⬇️
dm 24.90% <100.00%> (+0.04%) ⬆️
integrate 49.82% <100.00%> (-1.21%) ⬇️
playground 20.91% <ø> (ø)
tiup 16.37% <10.00%> (-0.02%) ⬇️
unittest 22.70% <25.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/cluster/embed/autogen_pkger.go 100.00% <100.00%> (ø)
pkg/cluster/spec/grafana.go 68.75% <100.00%> (+0.75%) ⬆️
pkg/cluster/template/config/grafana.go 75.00% <100.00%> (+5.76%) ⬆️
components/cluster/command/edit_config.go 33.33% <0.00%> (-44.45%) ⬇️
components/cluster/command/upgrade.go 37.50% <0.00%> (-37.50%) ⬇️
pkg/cluster/api/pdapi.go 30.28% <0.00%> (-28.40%) ⬇️
pkg/cluster/operation/upgrade.go 50.84% <0.00%> (-22.04%) ⬇️
pkg/cluster/spec/tikv.go 37.75% <0.00%> (-18.88%) ⬇️
pkg/utils/retry.go 47.36% <0.00%> (-18.43%) ⬇️
pkg/cluster/spec/pd.go 56.02% <0.00%> (-12.05%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09833d6...8b111b1. Read the comment docs.

@lucklove
Copy link
Member

In https://grafana.com/tutorials/run-grafana-behind-a-proxy/#1

It says:

When running Grafana behind a proxy, you need to configure the domain name to let Grafana know how to render links and redirects correctly.

And the final example is like:

[server]
domain = example.com
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
serve_from_sub_path = true

So I think maybe you forget to set the domain (by default, it's the IP address).

I suggest that you can add a Domain field and parse the domain from the root_url, if the root_url is not set, set Domain to the IP address.

@mianhk
Copy link
Contributor Author

mianhk commented Jan 23, 2021

In https://grafana.com/tutorials/run-grafana-behind-a-proxy/#1

It says:

When running Grafana behind a proxy, you need to configure the domain name to let Grafana know how to render links and redirects correctly.

And the final example is like:

[server]
domain = example.com
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
serve_from_sub_path = true

So I think maybe you forget to set the domain (by default, it's the IP address).

I suggest that you can add a Domain field and parse the domain from the root_url, if the root_url is not set, set Domain to the IP address.

OK,I add domain field parsed from domain if root_url is set or not cause someone may only set domain.

@lucklove
Copy link
Member

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lucklove

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 25, 2021
@lucklove
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 0d46b5e

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 25, 2021
@AstroProfundis AstroProfundis added the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Jan 25, 2021
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 25, 2021
…i to run a reverse proxy

add domain config of grafana.ini use tiup
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 25, 2021
@ti-chi-bot
Copy link
Member

@mianhk: Your PR has out-of-dated, I have automatically updated it for you.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit 8fb48a6 into pingcap:master Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time-contributor good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tiup supports config.ini for configuring grafana and prometheus
7 participants