Update email sender implementation

Using the new pinpoint email alarm implementation
This commit is contained in:
Marcos Alexandre de Melo 2019-01-03 09:32:04 -03:00 committed by Marcos Alexandre de Melo Medeiros
commit aaf494a227
11 changed files with 120 additions and 119 deletions

17
.env
View File

@ -41,17 +41,12 @@ 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=false
PINPOINT_URL=pinpoint.example.com
ALARM_MAIL_SERVER_URL=stmp.test.com
ALARM_MAIL_SERVER_PORT=123
ALARM_MAIL_SERVER_USERNAME=user
ALARM_MAIL_SERVER_PASSWORD=pass
### Pinpoint-Collector

View File

@ -17,6 +17,10 @@ It supports and helps you understand your application in a glance and allow you
- 1.7.3
- 1.7.2
## Requirements
- [docker 18.02.0+](https://docs.docker.com/compose/compose-file/)
## How to install Pinpoint?
You can easily bring up an entire Dockerized Pinpoint(latest release) environment by using [Docker Compose](https://docs.docker.com/compose/) with any of the provided `docker-compose.yml` files as below.
@ -25,7 +29,7 @@ To monitor your agent see [configuration part](#configurations) for further deta
```
git clone https://github.com/naver/pinpoint-docker.git
cd Pinpoint-Docker
cd pinpoint-docker
docker-compose pull && docker-compose up -d
```
If you'd like to bring up the previous release. Try with docker-compose file from other tags.
@ -34,28 +38,30 @@ You can also just build the image with `docker-compose up -d` command without pu
This will install and run all services required to run all features in Pinpoint in docker containers joined with same network.
- Pinpoint-Web Server
- Pinpoint-Collector
- Pinpoint-Agent(ready to be used)
- Pinpoint-Flink
- Pinpoint-Agent
- Pinpoint-Flink(to support certain feature)
- Pinpoint-Zookeeper
- Pinpoint-Hbase
- Pinpoint-QuickStart(a sample application)
- Pinpoint-Mysql
- Pinpoint-QuickStart(a sample application, 1.8.1+)
- Pinpoint-Mysql(to support certain feature)
This may take several minutes to download all necessary images.
You can replace `QuickStart` application part with your application to start monitoring.
- check [`Testing QuickStart application`](#testing-quickstart-application) for a quick demo of pinpoint
- check [`Monitoring YOUR Application`](#monitoring-your-application) part for further details
### Mysql (optional)
### Mysql (optional, 1.8.1+)
The Pinpoint-Mysql server is running on port 13306 and contains the data structure used to register users, groups, and alerts to be sent.
The Pinpoint-Mysql is necessary to use 'Alarm' feature. It's server is running on port 13306 and contains the data structure used to register users, groups, and alerts to be sent.
To send email alerts, you must make BATCH_ENABLE=true and change the other mail-related environment variables (MAIL_HOST, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD, MAIL_PROPERTIES_MAIL_SMTP_FROM, ...) to the Pinpoint-Web server in *.env* file.
To send email alerts, you must make BATCH_ENABLE=true and change the other mail-related environment variables (PINPOINT_URL, ALARM_MAIL_SERVER_URL, ALARM_MAIL_SERVER_PORT, ALARM_MAIL_SERVER_USERNAME, ALARM_MAIL_SERVER_PASSWORD, ALARM_MAIL_SENDER_ADDRESS, ...) to the Pinpoint-Web server in *.env* file.
For more information see [Setting Alarm](http://naver.github.io/pinpoint/alarm.html) in Pinpoint documentation.
For more information checkout [Setting Alarm](http://naver.github.io/pinpoint/alarm.html) in Pinpoint documentation.
### Flink configuration (optional)
The Pinpoint-Flink is necessary to use ['Application Inspector'](http://naver.github.io/pinpoint/applicationinspector.html) feature.
After all containers are started and ready to go. There is one more thing to do to use all existing features in Pinpoint.
It's not mandatory, but to use all the features and since it's a simple task, let's take care of it.

View File

@ -44,7 +44,7 @@ services:
container_name: pinpoint-mysql
restart: always
image: pinpointdocker/pinpoint-mysql:${PINPOINT_VERSION}
# image: "pinpointdocker/pinpoint-mysql:${PINPOINT_VERSION}"
hostname: pinpoint-mysql
ports:
- "13306:3306"
@ -95,17 +95,12 @@ services:
- JDBC_URL=${JDBC_URL}
- JDBC_USERNAME=${JDBC_USERNAME}
- JDBC_PASSWORD=${JDBC_PASSWORD}
- MAIL_HOST=${MAIL_HOST}
- MAIL_PORT=${MAIL_PORT}
- MAIL_USERNAME=${MAIL_USERNAME}
- MAIL_PASSWORD=${MAIL_PASSWORD}
- MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL=${MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL}
- MAIL_PROPERTIES_MAIL_SMTP_AUTH=${MAIL_PROPERTIES_MAIL_SMTP_AUTH}
- MAIL_PROPERTIES_MAIL_SMTP_PORT=${MAIL_PROPERTIES_MAIL_SMTP_PORT}
- MAIL_PROPERTIES_MAIL_SMTP_FROM=${MAIL_PROPERTIES_MAIL_SMTP_FROM}
- MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE=${MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE}
- MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED=${MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED}
- MAIL_PROPERTIES_MAIL_DEBUG=${MAIL_PROPERTIES_MAIL_DEBUG}
- PINPOINT_URL=${PINPOINT_URL}
- ALARM_MAIL_SERVER_URL=${ALARM_MAIL_SERVER_URL}
- ALARM_MAIL_SERVER_PORT=${ALARM_MAIL_SERVER_PORT}
- ALARM_MAIL_SERVER_USERNAME=${ALARM_MAIL_SERVER_USERNAME}
- ALARM_MAIL_SERVER_PASSWORD=${ALARM_MAIL_SERVER_PASSWORD}
- ALARM_MAIL_SENDER_ADDRESS=${ALARM_MAIL_SENDER_ADDRESS}
links:
- "pinpoint-mysql:pinpoint-mysql"
networks:

View File

@ -1 +1,7 @@
PINPOINT_VERSION=1.8.0
PINPOINT_VERSION=1.8.0
### Pinpoint-mysql
MYSQL_ROOT_PASSWORD=root123
MYSQL_USER=admin
MYSQL_PASSWORD=admin
MYSQL_DATABASE=pinpoint

38
pinpoint-mysql/Readme.md Normal file
View File

@ -0,0 +1,38 @@
## Pinpoint Mysql
This Docker image contains the Pinpoint Mysql component of the Pinpoint application monitoring system.
## Supported Tags
- 1.8.0
- 1.7.3
- 1.7.2
Please see [Pinpoint-Docker GitHub repository](https://github.com/naver/pinpoint-docker) for further information on how to run, configure and build this image.
## Any Issues or Suggestions?
Feel free to share any problems and suggestions via [Pinpoint GitHub Issue page](https://github.com/naver/pinpoint/issues).
Contributions on the pinpoint-docker image is also always welcome.
## License
Pinpoint is licensed under the Apache License, Version 2.0.
See [LICENSE](https://github.com/naver/pinpoint/blob/master/LICENSE) for full license text.
```
Copyright 2018 NAVER Corp.
Licensed 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.
```

View File

@ -0,0 +1,25 @@
version: "3.6"
services:
pinpoint-mysql:
build:
context: .
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=${MYSQL_ROOT_PASSWORD}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
volumes:
- ./var/lib/mysql

View File

@ -34,14 +34,9 @@ JDBC_USERNAME=
JDBC_PASSWORD=
#mail server information required
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL=
MAIL_PROPERTIES_MAIL_SMTP_AUTH=
MAIL_PROPERTIES_MAIL_SMTP_PORT=
MAIL_PROPERTIES_MAIL_SMTP_FROM=
MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE=
MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED=
MAIL_PROPERTIES_MAIL_DEBUG=
PINPOINT_URL=
ALARM_MAIL_SERVER_URL=
ALARM_MAIL_SERVER_PORT=
ALARM_MAIL_SERVER_USERNAME=
ALARM_MAIL_SERVER_PASSWORD=
ALARM_MAIL_SENDER_ADDRESS=

View File

@ -13,9 +13,6 @@ RUN chmod a+x /usr/local/bin/start-web.sh \
&& 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 \
&& 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
&& rm -rf pinpoint-web.war
ENTRYPOINT ["/usr/local/bin/start-web.sh"]

Binary file not shown.

View File

@ -16,70 +16,20 @@ sed -i "/batch.enable=/ s/=.*/=${BATCH_ENABLE}/" /usr/local/tomcat/webapps/ROOT/
sed -i "/batch.server.ip=/ s/=.*/=${BATCH_SERVER_IP}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/batch.properties
sed -i "/batch.flink.server=/ s/=.*/=${BATCH_FLINK_SERVER}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/batch.properties
sed -i "/level value=/ s/=.*/=\"${DEBUG_LEVEL}\"\/>/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.xml
sed -i "/pinpoint.url=/ s/=.*/=${PINPOINT_URL}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/batch.properties
sed -i "/alarm.mail.server.url=/ s/=.*/=${ALARM_MAIL_SERVER_URL}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/batch.properties
sed -i "/alarm.mail.server.port=/ s/=.*/=${ALARM_MAIL_SERVER_PORT}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/batch.properties
sed -i "/alarm.mail.server.userName=/ s/=.*/=${ALARM_MAIL_SERVER_USERNAME}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/batch.properties
sed -i "/alarm.mail.server.password=/ s/=.*/=${ALARM_MAIL_SERVER_PASSWORD}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/batch.properties
sed -i "/alarm.mail.sender.address=/ s/=.*/=${ALARM_MAIL_SENDER_ADDRESS}/" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/batch.properties
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
sed -i "/level value=/ s/=.*/=\"${DEBUG_LEVEL}\"\/>/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.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
" > /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/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
exec /usr/local/tomcat/bin/catalina.sh run

View File

@ -34,15 +34,9 @@ services:
- JDBC_URL=${JDBC_URL}
- JDBC_USERNAME=${JDBC_USERNAME}
- JDBC_PASSWORD=${JDBC_PASSWORD}
- MAIL_HOST=${MAIL_HOST}
- MAIL_PORT=${MAIL_PORT}
- MAIL_USERNAME=${MAIL_USERNAME}
- MAIL_PASSWORD=${MAIL_PASSWORD}
- MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL=${MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL}
- MAIL_PROPERTIES_MAIL_SMTP_AUTH=${MAIL_PROPERTIES_MAIL_SMTP_AUTH}
- MAIL_PROPERTIES_MAIL_SMTP_PORT=${MAIL_PROPERTIES_MAIL_SMTP_PORT}
- MAIL_PROPERTIES_MAIL_SMTP_FROM=${MAIL_PROPERTIES_MAIL_SMTP_FROM}
- MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE=${MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE}
- MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED=${MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED}
- MAIL_PROPERTIES_MAIL_DEBUG=${MAIL_PROPERTIES_MAIL_DEBUG}
- PINPOINT_URL=${PINPOINT_URL}
- ALARM_MAIL_SERVER_URL=${ALARM_MAIL_SERVER_URL}
- ALARM_MAIL_SERVER_PORT=${ALARM_MAIL_SERVER_PORT}
- ALARM_MAIL_SERVER_USERNAME=${ALARM_MAIL_SERVER_USERNAME}
- ALARM_MAIL_SERVER_PASSWORD=${ALARM_MAIL_SERVER_PASSWORD}
- ALARM_MAIL_SENDER_ADDRESS=${ALARM_MAIL_SENDER_ADDRESS}