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

[feature#3356] alert-spi support DingTalk&WeChat #3869

Merged
merged 30 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a9e3792
[feature-3665][ui]Add element-ui (#3666)
break60 Sep 4, 2020
2e117bb
Add form-create plug-in and alarm group management add sample demo
break60 Sep 7, 2020
50bfb30
Modify node version
break60 Sep 7, 2020
9221b24
fix
break60 Sep 7, 2020
8ac1462
fix
break60 Sep 7, 2020
3d5c34a
[feature][ui]Alert plugin design (#3734)
break60 Sep 22, 2020
392e9f5
[Feature-3189][alert,spi,dao,plugin-api] base code of dolphinschedule…
EricJoy2048 Sep 26, 2020
21dc62a
[feature#3356] alert-spi support DingTalk
CalvinKirs Oct 6, 2020
b5391e3
add test
CalvinKirs Oct 12, 2020
607de34
Merge branch 'alert_plugin_design' into ding_talk_alert
CalvinKirs Oct 12, 2020
d7b1e3d
code style
CalvinKirs Oct 12, 2020
23c00ca
Merge remote-tracking branch 'origin/ding_talk_alert' into ding_talk_…
CalvinKirs Oct 12, 2020
2397f93
we chat alert
CalvinKirs Oct 16, 2020
21fec40
support we chat alert
CalvinKirs Oct 17, 2020
43c8124
support we chat alert
CalvinKirs Oct 17, 2020
c8e9239
support we chat alert,update ding talk alert
CalvinKirs Oct 18, 2020
bc7ad24
code style
CalvinKirs Oct 18, 2020
9190f3d
add test
CalvinKirs Oct 18, 2020
bf4d888
code style
CalvinKirs Oct 18, 2020
ad60be0
clean old code
CalvinKirs Oct 18, 2020
0037851
clean old code
CalvinKirs Oct 18, 2020
5f50c7d
code smell
CalvinKirs Oct 18, 2020
a7ef283
code style
CalvinKirs Oct 18, 2020
d76a523
add test
CalvinKirs Oct 18, 2020
1a54bb2
simple config
CalvinKirs Oct 19, 2020
c2697d3
code style
CalvinKirs Oct 19, 2020
33dcf4d
code style
CalvinKirs Oct 19, 2020
5977d9f
code style
CalvinKirs Oct 19, 2020
f9d12d7
delete old file
CalvinKirs Oct 19, 2020
180e755
fix log content error
CalvinKirs Oct 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,7 @@ The text of each license is the standard Apache 2.0 license.
ScriptRunner from https://github.com/mybatis/mybatis-3 Apache 2.0
mvnw files from https://github.com/takari/maven-wrapper Apache 2.0
PropertyPlaceholderHelper from https://github.com/spring-projects/spring-framework Apache 2.0
DolphinPluginClassLoader from https://github.com/prestosql/presto Apache 2.0
DolphinPluginDiscovery from https://github.com/prestosql/presto Apache 2.0
DolphinPluginLoader from https://github.com/prestosql/presto Apache 2.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dolphinscheduler-alert-plugin</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<version>1.3.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-dingtalk</artifactId>

<dependencies>

<dependency>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-spi</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.dolphinscheduler.plugin.alert.dingtalk;

import org.apache.dolphinscheduler.spi.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.alert.AlertData;
import org.apache.dolphinscheduler.spi.alert.AlertInfo;
import org.apache.dolphinscheduler.spi.alert.AlertResult;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* DingTalkAlertChannel
*/
public class DingTalkAlertChannel implements AlertChannel {
private static final Logger logger = LoggerFactory.getLogger(DingTalkAlertChannel.class);

@Override
public AlertResult process(AlertInfo alertInfo) {

AlertData alertData = alertInfo.getAlertData();
String alertParams = alertInfo.getAlertParams();
List<PluginParams> pluginParams = JSONUtils.toList(alertParams, PluginParams.class);
CalvinKirs marked this conversation as resolved.
Show resolved Hide resolved
Map<String, String> paramsMap = new HashMap<>();
for (PluginParams param : pluginParams) {
paramsMap.put(param.getName(), param.getValue().toString());
}
AlertResult alertResult = new AlertResult();
alertResult.setStatus(Boolean.toString(Boolean.TRUE));
DingTalkSender dingTalkSender = new DingTalkSender(paramsMap);
try {
dingTalkSender.sendDingTalkMsg(alertData.getTitle(), alertData.getContent());
} catch (IOException e) {
alertResult.setStatus(Boolean.toString(Boolean.FALSE));
logger.error(e.getMessage(), e);
CalvinKirs marked this conversation as resolved.
Show resolved Hide resolved
}
return alertResult;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.dolphinscheduler.plugin.alert.dingtalk;

import org.apache.dolphinscheduler.spi.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.alert.AlertChannelFactory;
import org.apache.dolphinscheduler.spi.params.InputParam;
import org.apache.dolphinscheduler.spi.params.PasswordParam;
import org.apache.dolphinscheduler.spi.params.RadioParam;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;

import java.util.Arrays;
import java.util.List;

/**
* DingTalkAlertChannelFactory
*/
public class DingTalkAlertChannelFactory implements AlertChannelFactory {
@Override
public String getName() {
return "ding talk alert";
}

@Override
public List<PluginParams> getParams() {
InputParam webHookParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_WEB_HOOK, DingTalkParamsConstants.DING_TALK_WEB_HOOK)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam keywordParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_KEYWORD, DingTalkParamsConstants.DING_TALK_KEYWORD)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
RadioParam isEnableProxy =
RadioParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE, DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE)
.addParamsOptions(new ParamsOptions("NO", false, false))
CalvinKirs marked this conversation as resolved.
Show resolved Hide resolved
.setValue(true)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam proxyParam =
InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY, DingTalkParamsConstants.DING_TALK_PROXY)
.addValidate(Validate.newBuilder()
.setRequired(true).build())
.build();

InputParam portParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PORT, DingTalkParamsConstants.DING_TALK_PORT)
.addValidate(Validate.newBuilder()
.setRequired(true).build())
.build();

InputParam userParam =
InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_USER, DingTalkParamsConstants.DING_TALK_USER)
.addValidate(Validate.newBuilder()
.setRequired(true).build())
.build();
//todo
PasswordParam passwordParam = PasswordParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PASSWORD, DingTalkParamsConstants.DING_TALK_PASSWORD)
.setPlaceholder("if enable use authentication, you need input password")
.build();

return Arrays.asList(webHookParam, keywordParam, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
}

@Override
public AlertChannel create() {
return new DingTalkAlertChannel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.dolphinscheduler.plugin.alert.dingtalk;

import com.google.common.collect.ImmutableList;

import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
import org.apache.dolphinscheduler.spi.alert.AlertChannelFactory;

/**
* DingTalkAlertPlugin
*/
public class DingTalkAlertPlugin implements DolphinSchedulerPlugin {

@Override
public Iterable<AlertChannelFactory> getAlertChannelFactorys() {
return ImmutableList.of(new DingTalkAlertChannelFactory());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.plugin.alert.dingtalk;

/**
* DingTalkParamsConstants
*/
public class DingTalkParamsConstants {


public static final String DING_TALK_WEB_HOOK = "dingtalk.webhook";

public static final String NAME_DING_TALK_WEB_HOOK = "dingTalkWebHook";

public static final String DING_TALK_KEYWORD = "dingtalk.keyword";

public static final String NAME_DING_TALK_KEYWORD = "dingTalkKeyword";

public static final String DING_TALK_PROXY_ENABLE = "dingtalk.isEnableProxy";

public static final String NAME_DING_TALK_PROXY_ENABLE = "dingTalkIsEnableProxy";

public static final String DING_TALK_PROXY = "dingtalk.proxy";

public static final String NAME_DING_TALK_PROXY = "dingTalkProxy";

public static final String DING_TALK_PORT = "dingtalk.port";

public static final String NAME_DING_TALK_PORT = "dingTalkPort";

public static final String DING_TALK_USER = "dingtalk.user";

public static final String NAME_DING_TALK_USER = "dingTalkUser";

public static final String DING_TALK_PASSWORD = "dingtalk.password";

public static final String NAME_DING_TALK_PASSWORD = "dingTalkPassword";

public static final String DING_TALK_ENABLE = "dingtalk.isEnable";

public static final String NAME_DING_TALK_ENABLE = "dingTalkIsEnable";
}
Loading