Druid configuration and built-in monitoring, Web page view monitoring content

Source: Internet
Author: User

1. Configuring the Druid built-in monitoring

First introduce the package in the Pom.xml of the MAVEN project

<dependency>    <groupId>com.alibaba</groupId>    <artifactid>druid</artifactid >    <version>${druid-version}</version></dependency>

2. Configure the spring configuration file after the package is introduced

<!--reading configuration Files -<BeanID= "Propertyconfigurer"class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">    < Propertyname= "Locations">         <List>             <value>Classpath:jdbc.properties</value>         </List>     </ Property></Bean><!--Druid JNDI DataSource for EE environments -<BeanID= "DataSource"class= "Com.alibaba.druid.pool.DruidDataSource"Init-method= "Init"Destroy-method= "Close">    < Propertyname= "url"value= "${jdbc.url}" />    < Propertyname= "username"value= "${jdbc.username}" />    < Propertyname= "Password"value= "${jdbc.password}" />    < Propertyname= "Maxactive"value= " the" />    < Propertyname= "InitialSize"value= "1" />    < Propertyname= "Maxwait"value= "60000" />    < Propertyname= "Minidle"value= "1" />    < Propertyname= "Timebetweenevictionrunsmillis"value= " the" />    < Propertyname= "Minevictableidletimemillis"value= "300000" />    < Propertyname= "Validationquery"value= "Select ' x ' from DUAL" />    < Propertyname= "Testwhileidle"value= "true" />    < Propertyname= "Testonborrow"value= "false" />    < Propertyname= "Testonreturn"value= "false" />       <!--MySQL does not support poolpreparedstatements -    <!--<property name= "poolpreparedstatements" value= "true"/> -    <!--<property name= "maxpoolpreparedstatementperconnectionsize" value= "/> " -       <!--turn on the Druid Monitoring statistics function -    < Propertyname= "Filters"value= "Stat" /></Bean>

Then open the monitoring service in Web. xml

<!--Adding Druid monitoring -   <servlet>      <Servlet-name>Druidstatview</Servlet-name>      <Servlet-class>Com.alibaba.druid.support.http.StatViewServlet</Servlet-class>  </servlet>  <servlet-mapping>      <Servlet-name>Druidstatview</Servlet-name>      <Url-pattern>/druid/*</Url-pattern>  </servlet-mapping><!--add monitoring such as Web apps -  <Filter>    <Filter-name>Druidwebstatfilter</Filter-name>    <Filter-class>Com.alibaba.druid.support.http.WebStatFilter</Filter-class>    <Init-param>        <Param-name>Exclusions</Param-name>        <Param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</Param-value>    </Init-param>    <Init-param>        <Param-name>Profileenable</Param-name>        <Param-value>True</Param-value>    </Init-param>    <Init-param>        <Param-name>Principalcookiename</Param-name>        <Param-value>User_cookie</Param-value>    </Init-param>    <Init-param>        <Param-name>Principalsessionname</Param-name>        <Param-value>User_session</Param-value>    </Init-param></Filter><filter-mapping>    <Filter-name>Druidwebstatfilter</Filter-name>    <Url-pattern>/*</Url-pattern></filter-mapping>

Well, after the top three steps, you can monitor it. Visit Page Http://127.0.0.1:8080/{projectname}/druid/ Index.html can access the Monitoring page, Druid has data-friendly display to the page, including the number of times per SQL execution, execution time, the slowest time, and so much more detailed information, for our reference, to find out which are inefficient and time-consuming statements to optimize. At the same time provide data sources, SQL firewall, Web applications, URI monitoring, session monitoring, spring monitoring, etc., there are detailed information about various data, we can refer to the reference. ProjectName is the project name

Below is the Monitoring results page

Druid configuration and built-in monitoring, Web page view monitoring content

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.