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

api,config: enable audit-middleware in default config #5592

Merged
merged 4 commits into from
Oct 17, 2022

Conversation

CabinfeverB
Copy link
Member

@CabinfeverB CabinfeverB commented Oct 12, 2022

Signed-off-by: Cabinfever_B cabinfeveroier@gmail.com

default enable audit

Signed-off-by: Cabinfever_B cabinfeveroier@gmail.com

What problem does this PR solve?

Issue Number: ref #4480

What is changed and how does it work?

Check List

Tests

  • Unit test

  • Integration test

  • Manual test (add detailed scripts or steps below)
    image

  • Benchmark test result
    BenchmarkDoRequestWithLocalLogAudit

5206 211411 ns/op 26330 B/op 190 allocs/op
6152 247705 ns/op 26319 B/op 190 allocs/op

BenchmarkDoRequestWithPrometheusAudit

4790 351855 ns/op 31247 B/op 245 allocs/op
4512 276509 ns/op 30732 B/op 240 allocs/op

BenchmarkDoRequestWithoutServiceMiddleware

5767 237742 ns/op 26352 B/op 190 allocs/op
4887 209907 ns/op 26329 B/op 190 allocs/op

Code changes

  • Has configuration change

Release note

None.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Oct 12, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • nolouch
  • rleungx

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 submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Oct 12, 2022
@ti-chi-bot ti-chi-bot requested review from nolouch and rleungx October 12, 2022 18:10
@CabinfeverB CabinfeverB changed the title api,config: enable audit in default config api,config: enable audit-middleware in default config Oct 12, 2022
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

default enable audit

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

default enable audit

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@codecov
Copy link

codecov bot commented Oct 13, 2022

Codecov Report

Base: 75.74% // Head: 75.67% // Decreases project coverage by -0.06% ⚠️

Coverage data is based on head (5583226) compared to base (bc2019e).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5592      +/-   ##
==========================================
- Coverage   75.74%   75.67%   -0.07%     
==========================================
  Files         326      326              
  Lines       32251    32251              
==========================================
- Hits        24427    24405      -22     
- Misses       5722     5735      +13     
- Partials     2102     2111       +9     
Flag Coverage Δ
unittests 75.67% <100.00%> (-0.07%) ⬇️

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

Impacted Files Coverage Δ
server/config/service_middleware_config.go 100.00% <ø> (ø)
server/metrics.go 100.00% <ø> (ø)
pkg/audit/audit.go 91.66% <100.00%> (ø)
server/api/router.go 97.95% <100.00%> (ø)
pkg/dashboard/keyvisual/input/core.go 0.00% <0.00%> (-33.34%) ⬇️
server/storage/endpoint/rule.go 83.33% <0.00%> (-11.12%) ⬇️
pkg/tempurl/tempurl.go 60.00% <0.00%> (-10.00%) ⬇️
server/tso/local_allocator.go 64.86% <0.00%> (-6.76%) ⬇️
server/id/id.go 86.44% <0.00%> (-3.39%) ⬇️
server/schedulers/random_merge.go 62.50% <0.00%> (-3.13%) ⬇️
... and 22 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 13, 2022
@CabinfeverB
Copy link
Member Author

/run-monitor-test

@sre-bot
Copy link
Contributor

sre-bot commented Oct 13, 2022

Visit the grafana server at: http://172.16.5.21:30640, it will last for 5 hours

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

add grafana

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@nolouch
Copy link
Contributor

nolouch commented Oct 13, 2022

/run-monitor-test

@sre-bot
Copy link
Contributor

sre-bot commented Oct 13, 2022

Visit the grafana server at: http://172.16.5.21:32173, it will last for 5 hours

"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Completed commands rate",
Copy link
Member

Choose a reason for hiding this comment

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

How about adding HTTP prefix?


rulesHandler := newRulesHandler(svr, rd)
registerFunc(clusterRouter, "/config/rules", rulesHandler.GetAllRules, setMethods(http.MethodGet))
registerFunc(clusterRouter, "/config/rules", rulesHandler.SetAllRules, setMethods(http.MethodPost), setAuditBackend(localLog))
registerFunc(clusterRouter, "/config/rules/batch", rulesHandler.BatchRules, setMethods(http.MethodPost), setAuditBackend(localLog))
registerFunc(clusterRouter, "/config/rules", rulesHandler.SetAllRules, setMethods(http.MethodPost), setAuditBackend(localLog), setAuditBackend(prometheus))
Copy link
Member

Choose a reason for hiding this comment

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

Why change it?

Copy link
Member Author

Choose a reason for hiding this comment

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

add metrics for all API

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
registerFunc(clusterRouter, "/config/rules", rulesHandler.SetAllRules, setMethods(http.MethodPost), setAuditBackend(localLog), setAuditBackend(prometheus))
registerFunc(clusterRouter, "/config/rules", rulesHandler.SetAllRules, setMethods(http.MethodPost), setAuditBackend(localLog, prometheus))

registerFunc(apiRouter, "/members/id/{id}", memberHandler.DeleteMemberByID, setMethods(http.MethodDelete), setAuditBackend(localLog))
registerFunc(apiRouter, "/members/name/{name}", memberHandler.SetMemberPropertyByName, setMethods(http.MethodPost), setAuditBackend(localLog))
registerFunc(apiRouter, "/members", memberHandler.GetMembers, setMethods(http.MethodGet), setAuditBackend(prometheus))
registerFunc(apiRouter, "/members/name/{name}", memberHandler.DeleteMemberByName, setMethods(http.MethodDelete), setAuditBackend(localLog), setAuditBackend(prometheus))
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@rleungx
Copy link
Member

rleungx commented Oct 14, 2022

BTW, I suggest adding a comment to explain the principle of using logs or metrics.

registerFunc(apiRouter, "/config/replication-mode", confHandler.GetReplicationModeConfig, setMethods(http.MethodGet))
registerFunc(apiRouter, "/config/replication-mode", confHandler.SetReplicationModeConfig, setMethods(http.MethodPost))
registerFunc(apiRouter, "/config/replication-mode", confHandler.SetReplicationModeConfig, setMethods(http.MethodPost), setAuditBackend(localLog))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think also need for Prometheus for this api

@@ -8176,7 +8176,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Completed commands rate",
"title": " gRPC Completed commands rate",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"title": " gRPC Completed commands rate",
"title": "gRPC Completed commands rate",

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

all api supporting metrics

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

all api supporting metrics

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 14, 2022
@rleungx
Copy link
Member

rleungx commented Oct 17, 2022

/merge

@ti-chi-bot
Copy link
Member

@rleungx: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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
Copy link
Member

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

Commit hash: fe89dba

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 17, 2022
@ti-chi-bot
Copy link
Member

@CabinfeverB: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 19aa1c8 into tikv:master Oct 17, 2022
@CabinfeverB CabinfeverB deleted the default_enable_audit branch October 28, 2022 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants