How to create a Query monitoring component in Germain APM – see screencasts below:

Create a New Query Monitor Component

1. Navigate to System → Component Types

2. Click add/plus button


3. Select Database Query Monitor Component


4. Provide Name for component

5. Click Next


6. Select Database where the query will be run

7. Select credentials for DB access


8. Provide a name for the query

9. Write SQL query in SQL field, you can validate the query here as well

10. Click Next


11. Select KPI from drop-down list

You may choose to add custom KPI and rules (discussed below)

12. Click Next


13. Provide SLA threshold value

14. Click Finish


Add an additional query to an existing Query Monitor

1. Navigate to System → Component Types

2. Search for your component from the search bar (In our case it is called Sample Query Monitor Component)

3. Click on the component to edit it


4. Click the add/plus button under Queries section


5. Select Database and Credentials for the database

6. Click Next


7. Provide a name for the query

8. Write SQL query in SQL field, you can validate the query here as well

9. Click Next


10. Check Custom rule and select KPI

11. Click Finish


12. You can view all the queries for this component here

13. From this page you can enable, disable, delete or reorder the priority of queries


Create KPI for Query Monitor

1. Navigate to Analytics → KPIs

2. Click add/plus button


3. Provide Name

4. Choose Generic Event or Generic Transaction as Fact Class

5. Provide a unique name for Fact Category(i.e Query: Sample Query)


6. Select Fact-based SLA

7. Click Next


8. Provide Name for SLA

9. Provide threshold value in seconds

10. Choose color (i.e. Red, Orange)

11. Click Next


12. Optional Step. You may choose to add an alert. You can select them from the drop-down list

13. Click Finish



Add Portlet to Dashboard

1. Navigate to a dashboard where you would like to display data

2. Click add/plus button


3. Click Add Metric

4. Provide Name for Portlet

5. Select newly created KPI from dropdown list

6. Click Add Portlet

You may choose to modify settings here based on your requirements.


Your portlet will now be displayed on this dashboard.


Working with Rules

Rules are what translate data from the component and feed them to the database

You need to declare the data model Generic Transaction or Generic Event. Each field from the query has to be assigned to the fields in these data models

//Sample rule for OOTB component
rule "Component Crash"
when
    $msg : QueryResultMessage( category == "Component Crash" )
then
    GenericEvent event = new GenericEvent();
    event.type = "Component Crash";

    java.sql.Timestamp timestamp = (java.sql.Timestamp)$msg.results.get(0);
    event.timestamp = timestamp != null ? timestamp.toLocalDateTime() : null;
    
    event.application.name = $msg.getStringResult(3);
    event.application.component = $msg.getStringResult(1);
    event.name = $msg.getStringResult(2);
    event.details = $msg.getStringResult(6) + "\r\n" +  $msg.getStringResult(7);
    event.user.name = "Application_Value: " + $msg.getStringResult(9);
 
    datamart.insert(event, context);
    retract($msg);
end

CODE



Additional resources: