![Page 1: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/1.jpg)
AppDynamics Webinars:Building Custom ExtensionsTodd Radel, Senior Manager – Customer Advocacy
![Page 2: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/2.jpg)
Agenda
• Introduction• Writing a script extension• Writing a Java extension• Using your custom metrics• Best practices
• Office hours
![Page 3: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/3.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 3
About Me
Todd RadelSENIOR MANAGERCUSTOMER ADVOCACY TEAM
• More than 20 years experience in the software industry• Java, .NET, Python, Perl• Author of the Python SDK for AppDynamics REST API• Author of six AppDynamics Extensions: F5, Tibco EMS,
Redis, Keynote, SQL, URL Monitor
+1 (484) 857-2335
tradel
todd.radel
linkedin.com/in/tradel
![Page 4: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/4.jpg)
INTRODUCTION
![Page 5: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/5.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 5
What is an Extension?
• Plugs in to Machine Agent• Imports additional metrics to AppDynamics
![Page 6: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/6.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 6
Why Use Extensions?
“I already have Graphite/Nagios/my own custom tools…”
BUT:• Add more color to overall AppDynamics picture• Baseline and alert on custom metrics• Create custom dashboards• Work towards a “single pane of glass”
![Page 7: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/7.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 7
Example Extensions
• Apache Server Monitor• F5 Monitor• ActiveMQ Monitor
…or build your own!
![Page 8: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/8.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 8
Use Cases
• Run a SQL query every few minutes to count sales/signups/etc.
• Extract metrics from custom instrumentation• Eliminate redundant tools
![Page 9: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/9.jpg)
SCRIPT EXTENSIONS
![Page 10: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/10.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 10
Anatomy of a Simple Script Extension
• Script file• monitor.xml – describes the extension
![Page 11: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/11.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 11
Example
• Write an extension to count the number of files in /var/tmp and alert if there are too many
![Page 12: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/12.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 12
Simple Extension Script
![Page 13: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/13.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 13
Script Output
name=Custom Metrics|File Count|count, value=29, aggregator=OBSERVATION, time-rollup=CURRENT, cluster-rollup=COLLECTIVE
• name – path and name of your metric• value – metric value• aggregator – how to handle multiple values in one interval• time-rollup – how to aggregate values over time• cluster-rollup – how to aggregate values over nodes
![Page 14: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/14.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 14
Metric Aggregation
Aggregation Time Rollup Cluster Rollup
How should the controller handle multiple values in a single minute?
How should values be aggregated over time?
How should values be aggregated across nodes in a tier?
AVERAGEAverage of all reported values in that minute
AVERAGEAverage of all one-minute values
INDIVIDUALAverage of metric values across each node in the tier
SUMSum of all reported values in the minute
SUMSum of all one-minute values
COLLECTIVESum of metric values across each node in the tier
OBSERVATIONLast reported value in the minute
CURRENTLast reported one-minute value
![Page 15: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/15.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 15
Simple monitor.xml for a Script
”periodic” or “continuous”
script filename
![Page 16: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/16.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 16
OS-Specific monitor.xml for a Script
![Page 17: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/17.jpg)
JAVA EXTENSIONS
![Page 18: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/18.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 18
Anatomy of a Java Extension
• Class file or JAR file• Dependent libraries• Configuration file• monitor.xml
![Page 19: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/19.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 19
Structuring Your Java Code
• Can be a single class• Extend from
com.singularity.ee.agent.systemagent.api.AManagedMonitor• Override and implement execute() method• Call getMetricWriter().printMetric() to send data
![Page 20: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/20.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 20
Example
• Write an extension to import metrics from the Linux collectd(8) daemon
![Page 21: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/21.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 21
Sample Execute() Method
![Page 22: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/22.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 22
Configuring Your Extension
• Task arguments from monitor.xml are sent as first parameter to execute() method public TaskOutput execute(Map<String, String> args, TaskExecutionContext taskExecutionContext) throws TaskExecutionException {
• Configure via external file (e.g. config.yml), read the file during execute()
![Page 23: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/23.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 23
Monitor.xml for Java
![Page 24: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/24.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 24
Installation
![Page 25: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/25.jpg)
HTTP LISTENER
![Page 26: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/26.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 26
When to use the HTTP Listener
• When you don’t have control over the code• When the data collector runs on another machine
![Page 27: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/27.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 27
Starting Machine Agent with HTTP Listener
java ‑Dmetric.http.listener=true ‑Dmetric.http.listener.port=8000 -jar machineagent.jar
![Page 28: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/28.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 28
Sending Metric Data
![Page 29: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/29.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 29
Sending Metrics as JSON
![Page 30: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/30.jpg)
USING CUSTOM METRICS
![Page 31: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/31.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 31
Locating Your Custom Metrics
Tier name
Node name
Metric path
![Page 32: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/32.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 32
Create Custom Dashboards
![Page 33: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/33.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 33
Sample Custom Dashboard
![Page 34: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/34.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 34
Create Health Rules
![Page 35: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/35.jpg)
BEST PRACTICES
![Page 36: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/36.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 36
Best Practices
• Make it configurable via monitor.xml or config.yml• Allow a custom metric path• Write portable code• Send output to the machine agent log• Follow our “mavenized” project structure• Post the code on GitHub and encourage pull requests
![Page 37: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/37.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 37
Increasing the Agent Metric Limit
• If you don’t see all metrics in the controller UI• Check machine agent logs for “metric limit reached”• Add command line options and restart machine agent
• Without custom extensions:java -jar machineagent.jar
• With extensions:java -Xmx256m -Dappdynamics.agent.maxMetrics=10000 -jar machineagent.jar
![Page 38: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/38.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 38
Publishing Your Extension
• Remove any usernames/passwords/hostnames from configuration files
• Add README.md and LICENSE files• Post the code on GitHub• Create new thread on AppDynamics Community to
announce and publish!
![Page 39: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/39.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 39
Contents of Your README.md
• Description• Requirements• Installation• Configuration• Metrics Produced• How to Contribute (optional)• History/Release Notes• Screenshots
![Page 40: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/40.jpg)
FURTHER READING
![Page 41: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/41.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 41
Documentation
• Extensions and Custom Metrics• Build a Monitoring Extension Using Java• Build a Monitoring Extension Using Scripts• Machine Agent HTTP Listener
![Page 42: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/42.jpg)
Copyright © 2015 AppDynamics. All rights reserved. 42
Sample Java code
• Apache Monitoring Extension• URL Monitoring Extension
• Follow along as I finish these extensions!https://github.com/tradel/collectd-monitoring-extensionhttps://github.com/tradel/file-count-monitoring-extension
![Page 43: Webinar - Building Custom Extensions With AppDynamics](https://reader035.vdocuments.us/reader035/viewer/2022062306/5887d6341a28abfb678b4ce9/html5/thumbnails/43.jpg)
Thank You