You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ki...@apache.org on 2020/12/14 07:47:41 UTC

[incubator-dolphinscheduler] branch alert_plugin_design updated: [Alert plugin design] add http alert plugin (#4165)

This is an automated email from the ASF dual-hosted git repository.

kirs pushed a commit to branch alert_plugin_design
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git


The following commit(s) were added to refs/heads/alert_plugin_design by this push:
     new 9da6d58  [Alert plugin design] add http alert plugin (#4165)
9da6d58 is described below

commit 9da6d58d2ece8be0819c4356d56a4e170e83f848
Author: samz406 <sa...@foxmail.com>
AuthorDate: Mon Dec 14 15:47:32 2020 +0800

    [Alert plugin design] add http alert plugin (#4165)
    
    * add http alert plugin
---
 .../dolphinscheduler-alert-http/pom.xml            |  72 +++++++++
 .../plugin/alert/http/HttpAlertChannel.java        |  41 +++++
 .../plugin/alert/http/HttpAlertChannelFactory.java |  78 ++++++++++
 .../plugin/alert/http/HttpAlertConstants.java      |  35 +++++
 .../plugin/alert/http/HttpAlertPlugin.java         |  34 +++++
 .../plugin/alert/http/HttpSender.java              | 166 +++++++++++++++++++++
 .../alert/http/HttpAlertChannelFactoryTest.java    |  54 +++++++
 .../plugin/alert/http/HttpAlertChannelTest.java    | 104 +++++++++++++
 .../plugin/alert/http/HttpAlertPluginTest.java     |  38 +++++
 .../plugin/alert/http/HttpSenderTest.java          |  46 ++++++
 dolphinscheduler-alert-plugin/pom.xml              |   1 +
 pom.xml                                            |   4 +
 12 files changed, 673 insertions(+)

diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/pom.xml b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/pom.xml
new file mode 100644
index 0000000..21440d8
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/pom.xml
@@ -0,0 +1,72 @@
+<?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>
+
+    <artifactId>dolphinscheduler-alert-http</artifactId>
+    <packaging>dolphinscheduler-plugin</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-spi</artifactId>
+            <scope>provided</scope>
+        </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.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <type>jar</type>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java
new file mode 100644
index 0000000..27bc190
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java
@@ -0,0 +1,41 @@
+/*
+ * 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.http;
+
+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.PluginParamsTransfer;
+
+import java.util.Map;
+
+/**
+ * http alert channel,use sms message to seed the alertInfo
+ */
+public class HttpAlertChannel implements AlertChannel {
+    @Override
+    public AlertResult process(AlertInfo alertInfo) {
+
+        AlertData alertData = alertInfo.getAlertData();
+        String alertParams = alertInfo.getAlertParams();
+        Map<String, String> paramsMap = PluginParamsTransfer.getPluginParamsMap(alertParams);
+
+        return new HttpSender(paramsMap).send(alertData.getContent());
+    }
+}
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java
new file mode 100644
index 0000000..805c9b3
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactory.java
@@ -0,0 +1,78 @@
+/*
+ * 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.http;
+
+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.base.PluginParams;
+import org.apache.dolphinscheduler.spi.params.base.Validate;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * http alert factory
+ */
+public class HttpAlertChannelFactory implements AlertChannelFactory {
+    @Override
+    public String getName() {
+        return "http alert";
+    }
+
+    @Override
+    public List<PluginParams> getParams() {
+
+        InputParam url = InputParam.newBuilder(HttpAlertConstants.URL, HttpAlertConstants.URL)
+                .addValidate(Validate.newBuilder()
+                        .setRequired(true)
+                        .build())
+                .build();
+
+        InputParam headerParams = InputParam.newBuilder(HttpAlertConstants.HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
+                .addValidate(Validate.newBuilder()
+                        .setRequired(true)
+                        .build())
+                .build();
+
+        InputParam bodyParams = InputParam.newBuilder(HttpAlertConstants.BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
+                .addValidate(Validate.newBuilder()
+                        .setRequired(true)
+                        .build())
+                .build();
+
+        InputParam contentField = InputParam.newBuilder(HttpAlertConstants.CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
+                .addValidate(Validate.newBuilder()
+                        .setRequired(true)
+                        .build())
+                .build();
+
+        InputParam requestType = InputParam.newBuilder(HttpAlertConstants.REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
+                .addValidate(Validate.newBuilder()
+                        .setRequired(true)
+                        .build())
+                .build();
+
+        return Arrays.asList(url, requestType, headerParams, bodyParams, contentField);
+    }
+
+    @Override
+    public AlertChannel create() {
+        return new HttpAlertChannel();
+    }
+}
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java
new file mode 100644
index 0000000..965860d
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertConstants.java
@@ -0,0 +1,35 @@
+/*
+ * 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.http;
+
+public class HttpAlertConstants {
+
+    private HttpAlertConstants() {
+    }
+
+    public static final String URL = "url";
+
+    public static final String HEADER_PARAMS = "headerParams";
+
+    public static final String BODY_PARAMS = "bodyParams";
+
+    public static final String CONTENT_FIELD = "contentField";
+
+    public static final String REQUEST_TYPE = "requestType";
+
+}
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertPlugin.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertPlugin.java
new file mode 100644
index 0000000..973f161
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertPlugin.java
@@ -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.http;
+
+import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
+import org.apache.dolphinscheduler.spi.alert.AlertChannelFactory;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * http  alertPlugins
+ */
+public class HttpAlertPlugin implements DolphinSchedulerPlugin {
+
+    @Override
+    public Iterable<AlertChannelFactory> getAlertChannelFactorys() {
+        return ImmutableList.of(new HttpAlertChannelFactory());
+    }
+}
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
new file mode 100644
index 0000000..32d3cdb
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
@@ -0,0 +1,166 @@
+/*
+ * 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.http;
+
+import org.apache.dolphinscheduler.spi.alert.AlertResult;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+import org.apache.dolphinscheduler.spi.utils.StringUtils;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * http  send message
+ */
+public class HttpSender {
+
+    public static final Logger logger = LoggerFactory.getLogger(HttpSender.class);
+
+    private String url;
+
+    private final String headerParams;
+
+    private final String bodyParams;
+
+    private final String contentField;
+
+    private final String requestType;
+
+    private HttpRequestBase httpRequest;
+
+
+    private static final String URL_SPLICE_CHAR = "?";
+
+    /**
+     * request type post
+     */
+    private static final String REQUEST_TYPE_POST = "POST";
+
+    /**
+     * request type get
+     */
+    private static final String REQUEST_TYPE_GET = "GET";
+
+    private static final String DEFAULT_CHARSET = "utf-8";
+
+    public HttpSender(Map<String, String> paramsMap) {
+
+        url = paramsMap.get(HttpAlertConstants.URL);
+        headerParams = paramsMap.get(HttpAlertConstants.HEADER_PARAMS);
+        bodyParams = paramsMap.get(HttpAlertConstants.BODY_PARAMS);
+        contentField = paramsMap.get(HttpAlertConstants.CONTENT_FIELD);
+        requestType = paramsMap.get(HttpAlertConstants.REQUEST_TYPE);
+    }
+
+    public AlertResult send(String msg) {
+
+        AlertResult alertResult = new AlertResult();
+
+        createHttpRequest(msg);
+
+        if (httpRequest == null) {
+            alertResult.setStatus("false");
+            alertResult.setMessage("Request types are not supported");
+            return alertResult;
+        }
+
+        try {
+            CloseableHttpClient httpClient = HttpClientBuilder.create().build();
+            CloseableHttpResponse response = httpClient.execute(httpRequest);
+            HttpEntity entity = response.getEntity();
+            String resp = EntityUtils.toString(entity, DEFAULT_CHARSET);
+            alertResult.setStatus("true");
+            alertResult.setMessage(resp);
+        } catch (Exception e) {
+            logger.error("send http alert msg  exception : {}", e.getMessage());
+            alertResult.setStatus("false");
+            alertResult.setMessage("send http request  alert fail.");
+        }
+
+        return alertResult;
+    }
+
+    private void createHttpRequest(String msg) {
+
+        if (REQUEST_TYPE_POST.equals(requestType)) {
+            httpRequest = new HttpPost(url);
+            //POST request add param in request body
+            setMsgInRequestBody(msg);
+        } else if (REQUEST_TYPE_GET.equals(requestType)) {
+            //GET request add param in url
+            setMsgInUrl(msg);
+            httpRequest = new HttpGet(url);
+        }
+        setHeader();
+    }
+
+    /**
+     * add msg param in url
+     */
+    private void setMsgInUrl(String msg) {
+
+        if (StringUtils.isNotBlank(contentField)) {
+            String type = "&";
+            //check splice char is & or ?
+            if (!url.contains(URL_SPLICE_CHAR)) {
+                type = URL_SPLICE_CHAR;
+            }
+            url = String.format("%s%s%s=%s", url, type, contentField, msg);
+        }
+    }
+
+    /**
+     * set header params
+     */
+    private void setHeader() {
+
+        if (httpRequest == null) {
+            return;
+        }
+
+        HashMap<String, Object> map = JSONUtils.parseObject(headerParams, HashMap.class);
+        for (Map.Entry<String, Object> entry : map.entrySet()) {
+            httpRequest.setHeader(entry.getKey(), String.valueOf(entry.getValue()));
+        }
+    }
+
+    /**
+     * set body params
+     */
+    private String setMsgInRequestBody(String msg) {
+        ObjectNode objectNode = JSONUtils.parseObject(bodyParams);
+        //set msg content field
+        objectNode.put(contentField, msg);
+        return objectNode.toString();
+    }
+
+}
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactoryTest.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactoryTest.java
new file mode 100644
index 0000000..25181eb
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelFactoryTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.http;
+
+import org.apache.dolphinscheduler.spi.alert.AlertChannel;
+import org.apache.dolphinscheduler.spi.params.base.PluginParams;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * HttpAlertChannelFactory UT
+ */
+public class HttpAlertChannelFactoryTest {
+
+    private HttpAlertChannelFactory httpAlertChannelFactory;
+
+    @Before
+    public void init() {
+        httpAlertChannelFactory = new HttpAlertChannelFactory();
+    }
+
+    @Test
+    public void getParamsTest() {
+
+        List<PluginParams> pluginParamsList = httpAlertChannelFactory.getParams();
+        Assert.assertEquals(5, pluginParamsList.size());
+    }
+
+    @Test
+    public void createTest() {
+        AlertChannel alertChannel = httpAlertChannelFactory.create();
+        Assert.assertNotNull(alertChannel);
+    }
+
+}
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelTest.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelTest.java
new file mode 100644
index 0000000..31a438b
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.http;
+
+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.InputParam;
+import org.apache.dolphinscheduler.spi.params.base.PluginParams;
+import org.apache.dolphinscheduler.spi.params.base.Validate;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * HttpAlertChannel UT
+ */
+public class HttpAlertChannelTest {
+
+    @Test
+    public void processTest() {
+
+        HttpAlertChannel alertChannel = new HttpAlertChannel();
+        AlertInfo alertInfo = new AlertInfo();
+        AlertData alertData = new AlertData();
+        alertData.setContent("Fault tolerance warning");
+        alertInfo.setAlertData(alertData);
+        AlertResult alertResult = alertChannel.process(alertInfo);
+        Assert.assertEquals("Request types are not supported", alertResult.getMessage());
+    }
+
+    @Test
+    public void processTest2() {
+
+        HttpAlertChannel alertChannel = new HttpAlertChannel();
+        AlertInfo alertInfo = new AlertInfo();
+        AlertData alertData = new AlertData();
+        alertData.setContent("Fault tolerance warning");
+        alertInfo.setAlertData(alertData);
+        alertInfo.setAlertParams(getParams());
+        AlertResult alertResult = alertChannel.process(alertInfo);
+        Assert.assertEquals("true", alertResult.getStatus());
+    }
+
+    /**
+     * create params
+     */
+    private String getParams() {
+
+        List<PluginParams> paramsList = new ArrayList<>();
+        InputParam urlParam = InputParam.newBuilder("url", "url")
+                .setValue("http://www.baidu.com")
+                .addValidate(Validate.newBuilder().setRequired(true).build())
+                .build();
+
+        InputParam headerParams = InputParam.newBuilder("headerParams", "headerParams")
+                .addValidate(Validate.newBuilder().setRequired(true).build())
+                .setValue("{\"Content-Type\":\"application/json\"}")
+                .build();
+
+        InputParam bodyParams = InputParam.newBuilder("bodyParams", "bodyParams")
+                .addValidate(Validate.newBuilder().setRequired(true).build())
+                .setValue("{\"number\":\"13457654323\"}")
+                .build();
+
+        InputParam content = InputParam.newBuilder("contentField", "contentField")
+                .setValue("content")
+                .addValidate(Validate.newBuilder().setRequired(true).build())
+                .build();
+
+        InputParam requestType = InputParam.newBuilder("requestType", "requestType")
+                .setValue("POST")
+                .addValidate(Validate.newBuilder().setRequired(true).build())
+                .build();
+
+        paramsList.add(urlParam);
+        paramsList.add(headerParams);
+        paramsList.add(bodyParams);
+        paramsList.add(content);
+        paramsList.add(requestType);
+
+        return JSONUtils.toJsonString(paramsList);
+    }
+
+}
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertPluginTest.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertPluginTest.java
new file mode 100644
index 0000000..7dac686
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertPluginTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.http;
+
+import org.apache.dolphinscheduler.spi.alert.AlertChannelFactory;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * HttpAlertPlugin UT
+ */
+public class HttpAlertPluginTest {
+
+    @Test
+    public void getAlertChannelFactorysTest() {
+
+        HttpAlertPlugin httpAlertPlugin = new HttpAlertPlugin();
+        Iterable<AlertChannelFactory> alertChannelFactorys = httpAlertPlugin.getAlertChannelFactorys();
+        Assert.assertNotNull(alertChannelFactorys);
+
+    }
+}
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java
new file mode 100644
index 0000000..d59c4d4
--- /dev/null
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSenderTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.http;
+
+import org.apache.dolphinscheduler.spi.alert.AlertResult;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * HttpSender UT
+ */
+public class HttpSenderTest {
+
+    @Test
+    public void sendTest() {
+
+        Map<String, String> paramsMap = new HashMap<>();
+        paramsMap.put(HttpAlertConstants.URL, "http://www.baidu.com");
+        paramsMap.put(HttpAlertConstants.REQUEST_TYPE, "POST");
+        paramsMap.put(HttpAlertConstants.HEADER_PARAMS, "{\"Content-Type\":\"application/json\"}");
+        paramsMap.put(HttpAlertConstants.BODY_PARAMS, "{\"number\":\"13457654323\"}");
+        paramsMap.put(HttpAlertConstants.CONTENT_FIELD, "content");
+        HttpSender httpSender = new HttpSender(paramsMap);
+        AlertResult alertResult = httpSender.send("Fault tolerance warning");
+        Assert.assertEquals("true", alertResult.getStatus());
+    }
+}
diff --git a/dolphinscheduler-alert-plugin/pom.xml b/dolphinscheduler-alert-plugin/pom.xml
index 0f25f1f..707f0ce 100644
--- a/dolphinscheduler-alert-plugin/pom.xml
+++ b/dolphinscheduler-alert-plugin/pom.xml
@@ -34,6 +34,7 @@
         <module>dolphinscheduler-alert-wechat</module>
         <module>dolphinscheduler-alert-dingtalk</module>
         <module>dolphinscheduler-alert-script</module>
+        <module>dolphinscheduler-alert-http</module>
     </modules>
 
 
diff --git a/pom.xml b/pom.xml
index 5f49824..9c154bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -960,6 +960,10 @@
                         <include>**/plugin/alert/script/ProcessUtilsTest.java</include>
                         <include>**/plugin/alert/script/ScriptAlertChannelFactoryTest.java</include>
                         <include>**/plugin/alert/script/ScriptSenderTest.java</include>
+                        <include>**/plugin/alert/http/HttpAlertChannelFactoryTest.java</include>
+                        <include>**/plugin/alert/http/HttpAlertChannelTest.java</include>
+                        <include>**/plugin/alert/http/HttpAlertPluginTest.java</include>
+                        <include>**/plugin/alert/http/HttpSenderTest.java</include>
                         <include>**/spi/params/PluginParamsTransferTest.java</include>
                         <!--<include>**/alert/plugin/EmailAlertPluginTest.java</include>-->
                         <include>**/alert/plugin/AlertPluginManagerTest.java</include>