-
Notifications
You must be signed in to change notification settings - Fork 5k
[feature#14654] alert-spi support prometheus alertmanager #15079
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
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #15079 +/- ##
============================================
+ Coverage 38.17% 38.24% +0.07%
- Complexity 4681 4693 +12
============================================
Files 1281 1285 +4
Lines 45350 45412 +62
Branches 4941 4926 -15
============================================
+ Hits 17311 17367 +56
- Misses 26151 26154 +3
- Partials 1888 1891 +3
... and 27 files with indirect coverage changes 📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
...us/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/AlertManagerSender.java
Fixed
Show fixed
Hide fixed
...us/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/AlertManagerSender.java
Fixed
Show fixed
Hide fixed
| } | ||
|
|
||
| private static CloseableHttpClient getDefaultClient() { | ||
| return HttpClients.createDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 110 to 116 in a5284e4
| public String getResponseString(HttpRequestBase httpRequest) throws IOException { | |
| CloseableHttpClient httpClient = | |
| HttpClients.custom().setRetryHandler(HttpServiceRetryStrategy.retryStrategy).build(); | |
| CloseableHttpResponse response = httpClient.execute(httpRequest); | |
| HttpEntity entity = response.getEntity(); | |
| return EntityUtils.toString(entity, DEFAULT_CHARSET); | |
| } |
Based on the implementation of other plugins, it is recommended to use an HTTP client that supports retrying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
Gallardot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM.
|
|
||
| @BeforeEach | ||
| public void initConfig() { | ||
| config.put(AlertManagerConstants.NAME_ALERT_MANAGER_URL, "http://127.0.0.1:9093"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this unit test mock an AlertManager-Server and pass the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set the unit test result to false. If need, I can add test to mock an AlertManager-Server. I did not add it for there is no mock for third server in any other alert plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. LGTM.
|
@SbloodyS @Radeity @EricGao888 @qingwli PTAL. |
...nscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertInputTips.java
Outdated
Show resolved
Hide resolved
...us/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/AlertManagerSender.java
Outdated
Show resolved
Hide resolved
...us/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/AlertManagerSender.java
Outdated
Show resolved
Hide resolved
...us/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/AlertManagerSender.java
Outdated
Show resolved
Hide resolved
...us/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/AlertManagerSender.java
Outdated
Show resolved
Hide resolved
...us/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/AlertManagerSender.java
Outdated
Show resolved
Hide resolved
...us/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/AlertManagerSender.java
Outdated
Show resolved
Hide resolved
|
In addition, file name in package |
OK |
| log.error("send prometheus alert manager alert msg exception: {}", e.getMessage()); | ||
| alertResult = new AlertResult(); | ||
| alertResult.setStatus("false"); | ||
| alertResult.setMessage("send prometheus alert manager alert fail."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add error into the message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC
qingwli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Others LGTM
...src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSender.java
Outdated
Show resolved
Hide resolved
…cheduler-alert-prometheus/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSender.java Co-authored-by: 旺阳 <[email protected]>
qingwli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
PTAL @Radeity |
|
Kudos, SonarCloud Quality Gate passed! |








Purpose of the pull request
To add alert-api for prometheus alertmanager close #14654.
The implementation principle is to request its alert interface through http client to generate an alert.
api document
Brief change log
a new moudle dolphinscheduler-alert-prometheus be added
Verify this pull request
create alert instance to test it.

