Send alarms by email

Addition of mysql container with pinpoint database to allow the 
registration of users, groups and alarms.

Including lib, implementation of AlarmMessageSender and settings 
in the pinpoint-web container to allow sending alert emails.
This commit is contained in:
marcos 2018-12-18 13:48:28 -03:00
parent aa4767725d
commit 2baa58e056
5 changed files with 122 additions and 1 deletions

View File

@ -35,6 +35,30 @@ services:
- "16030:16030"
restart: always
pinpoint-mysql:
build:
context: ./pinpoint-mysql/
dockerfile: Dockerfile
args:
- PINPOINT_VERSION=${PINPOINT_VERSION}
container_name: pinpoint-mysql
restart: always
image: pinpointdocker/pinpoint-mysql:${PINPOINT_VERSION}
hostname: pinpoint-mysql
ports:
- "13306:3306"
environment:
MYSQL_ROOT_PASSWORD: root123
MYSQL_USER: admin
MYSQL_PASSWORD: admin
MYSQL_DATABASE: pinpoint
volumes:
- mysql_data:/var/lib/mysql
networks:
- pinpoint
pinpoint-web:
build:
context: ./pinpoint-web/
@ -47,6 +71,7 @@ services:
depends_on:
- pinpoint-hbase
- pinpoint-mysql
restart: always
expose:
- "8080"
@ -66,6 +91,23 @@ services:
- BATCH_ENABLE=${BATCH_ENABLE}
- BATCH_SERVER_IP=${BATCH_SERVER_IP}
- BATCH_FLINK_SERVER=${BATCH_FLINK_SERVER}
- JDBC_DRIVER=com.mysql.jdbc.Driver
- JDBC_URL=jdbc:mysql://pinpoint-mysql:3306/pinpoint?characterEncoding=UTF-8
- JDBC_USERNAME=admin
- JDBC_PASSWORD=admin
- MAIL_HOST=stmp.test.com
- MAIL_PORT=123
- MAIL_USERNAME=user
- MAIL_PASSWORD=pass
# - MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL=smtp
- MAIL_PROPERTIES_MAIL_SMTP_AUTH='true'
- MAIL_PROPERTIES_MAIL_SMTP_PORT=587
# - MAIL_PROPERTIES_MAIL_SMTP_FROM=test@example.com
- MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE='true'
# - MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED='true'
# - MAIL_PROPERTIES_MAIL_DEBUG='true'
links:
- "pinpoint-mysql:pinpoint-mysql"
networks:
- pinpoint
@ -215,6 +257,7 @@ services:
volumes:
data-volume:
mysql_data:
networks:
pinpoint:

11
pinpoint-mysql/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM mysql:5.7
ENV PINPOINT_VERSION=1.8.0
RUN apt update \
&& apt-get install -y --no-install-recommends ca-certificates wget \
&& wget -O /docker-entrypoint-initdb.d/CreateTableStatement-mysql.sql "https://raw.githubusercontent.com/naver/pinpoint/$PINPOINT_VERSION/web/src/main/resources/sql/CreateTableStatement-mysql.sql" \
&& wget -O /docker-entrypoint-initdb.d/SpringBatchJobRepositorySchema-mysql.sql "https://raw.githubusercontent.com/naver/pinpoint/$PINPOINT_VERSION/web/src/main/resources/sql/SpringBatchJobRepositorySchema-mysql.sql" \
&& sed -i '/^--/d' /docker-entrypoint-initdb.d/CreateTableStatement-mysql.sql \
&& sed -i '/^--/d' /docker-entrypoint-initdb.d/SpringBatchJobRepositorySchema-mysql.sql \
&& apt-get purge -y --auto-remove ca-certificates wget

View File

@ -6,12 +6,16 @@ ARG PINPOINT_VERSION=${PINPOINT_VERSION:-1.8.0}
ARG INSTALL_URL=https://github.com/naver/pinpoint/releases/download/${PINPOINT_VERSION}/pinpoint-web-${PINPOINT_VERSION}.war
COPY /build/scripts/start-web.sh /usr/local/bin/
COPY /build/mail.zip /assets/mail.zip
RUN chmod a+x /usr/local/bin/start-web.sh \
&& curl -SL ${INSTALL_URL} -o pinpoint-web.war \
&& rm -rf /usr/local/tomcat/webapps \
&& mkdir -p /usr/local/tomcat/webapps \
&& unzip pinpoint-web.war -d /usr/local/tomcat/webapps/ROOT \
&& rm -rf pinpoint-web.war
&& rm -rf pinpoint-web.war \
&& curl -SL https://maven.java.net/content/repositories/releases/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar -o /usr/local/tomcat/webapps/ROOT/WEB-INF/lib/javax.mail-1.5.2.jar \
&& unzip /assets/mail.zip -d /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/ \
&& rm -rf /assets/mail.zip
ENTRYPOINT ["/usr/local/bin/start-web.sh"]

BIN
pinpoint-web/build/mail.zip Normal file

Binary file not shown.

View File

@ -18,5 +18,68 @@ sed -i "/batch.flink.server=/ s/=.*/=${BATCH_FLINK_SERVER}/" /usr/local/tomcat/w
sed -i "/level value=/ s/=.*/=\"${DEBUG_LEVEL}\"\/>/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.xml
WEB_INF_CLASSES_DIR=/usr/local/tomcat/webapps/ROOT/WEB-INF/classes
APPLICATION_CONTEXT_WEB_FILE=${WEB_INF_CLASSES_DIR}/applicationContext-web.xml
APPLICATION_CONTEXT_MAIL_FILE=${WEB_INF_CLASSES_DIR}/applicationContext-mail.xml
echo -e "
jdbc.driverClassName=${JDBC_DRIVER:-com.mysql.jdbc.Driver}
jdbc.url=${JDBC_URL:-jdbc:mysql://localhost:13306/pinpoint?characterEncoding=UTF-8}
jdbc.username=${JDBC_USERNAME:-admin}
jdbc.password=${JDBC_PASSWORD:-admin}
" > ${WEB_INF_CLASSES_DIR}/jdbc.properties
sed -i '/classpath:applicationContext-mail.xml/d' ${APPLICATION_CONTEXT_WEB_FILE}
if [ "$MAIL_HOST" != "" ]; then
sed -i 's/<\/beans>/ <import resource="classpath:applicationContext-mail.xml" \/>\
<\/beans>/' ${APPLICATION_CONTEXT_WEB_FILE}
sed -i "/name=\"host\"/c\ <property name=\"host\" value=\"${MAIL_HOST}\" />" ${APPLICATION_CONTEXT_MAIL_FILE}
sed -i "/name=\"port\"/c\ <property name=\"port\" value=\"${MAIL_PORT}\" />" ${APPLICATION_CONTEXT_MAIL_FILE}
sed -i "/name=\"username\"/c\ <property name=\"username\" value=\"${MAIL_USERNAME}\" />" ${APPLICATION_CONTEXT_MAIL_FILE}
sed -i "/name=\"password\"/c\ <property name=\"password\" value=\"${MAIL_PASSWORD}\" />" ${APPLICATION_CONTEXT_MAIL_FILE}
if [ "$MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL" != "" ]; then
sed -i "/prop key=\"mail.transport.protocol\"/c\ <prop key=\"mail.transport.protocol\">${MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL}</prop>" ${APPLICATION_CONTEXT_MAIL_FILE}
else
sed -i "/prop key=\"mail.transport.protocol\"/c\ <!-- <prop key=\"mail.transport.protocol\">smtp</prop> -->" ${APPLICATION_CONTEXT_MAIL_FILE}
fi
if [ "$MAIL_PROPERTIES_MAIL_SMTP_PORT" != "" ]; then
sed -i "/prop key=\"mail.smtp.port\"/c\ <prop key=\"mail.smtp.port\">${MAIL_PROPERTIES_MAIL_SMTP_PORT}</prop>" ${APPLICATION_CONTEXT_MAIL_FILE}
else
sed -i "/prop key=\"mail.smtp.port\"/c\ <!-- <prop key=\"mail.smtp.port\">25</prop> -->" ${APPLICATION_CONTEXT_MAIL_FILE}
fi
if [ "$MAIL_PROPERTIES_MAIL_SMTP_AUTH" != "" ]; then
sed -i "/prop key=\"mail.smtp.auth\"/c\ <prop key=\"mail.smtp.auth\">${MAIL_PROPERTIES_MAIL_SMTP_AUTH}</prop>" ${APPLICATION_CONTEXT_MAIL_FILE}
else
sed -i "/prop key=\"mail.smtp.auth\"/c\ <!-- <prop key=\"mail.smtp.auth\">true</prop> -->" ${APPLICATION_CONTEXT_MAIL_FILE}
fi
if [ "$MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE" != "" ]; then
sed -i "/prop key=\"mail.smtp.starttls.enable\"/c\ <prop key=\"mail.smtp.starttls.enable\">${MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE}</prop>" ${APPLICATION_CONTEXT_MAIL_FILE}
else
sed -i "/prop key=\"mail.smtp.starttls.enable\"/c\ <!-- <prop key=\"mail.smtp.starttls.enable\">true</prop> -->" ${APPLICATION_CONTEXT_MAIL_FILE}
fi
if [ "$MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED" != "" ]; then
sed -i "/prop key=\"mail.smtp.starttls.required\"/c\ <prop key=\"mail.smtp.starttls.required\">${MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED}</prop>" ${APPLICATION_CONTEXT_MAIL_FILE}
else
sed -i "/prop key=\"mail.smtp.starttls.required\"/c\ <!-- <prop key=\"mail.smtp.starttls.required\">true</prop> -->" ${APPLICATION_CONTEXT_MAIL_FILE}
fi
if [ "$MAIL_PROPERTIES_MAIL_DEBUG" != "" ]; then
sed -i "/prop key=\"mail.debug\"/c\ <prop key=\"mail.debug\">${MAIL_PROPERTIES_MAIL_DEBUG}</prop>" ${APPLICATION_CONTEXT_MAIL_FILE}
else
sed -i "/prop key=\"mail.debug\"/c\ <!-- <prop key=\"mail.debug\">true</prop> -->" ${APPLICATION_CONTEXT_MAIL_FILE}
fi
if [ "$MAIL_PROPERTIES_MAIL_SMTP_FROM" != "" ]; then
sed -i "/prop key=\"mail.smtp.from\"/c\ <prop key=\"mail.smtp.from\">${MAIL_PROPERTIES_MAIL_SMTP_FROM}</prop>" ${APPLICATION_CONTEXT_MAIL_FILE}
else
sed -i "/prop key=\"mail.smtp.from\"/c\ <!-- <prop key=\"mail.smtp.from\">abc@example.com</prop> -->" ${APPLICATION_CONTEXT_MAIL_FILE}
fi
fi
exec /usr/local/tomcat/bin/catalina.sh run