cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Abhi.Bajaj
AppDynamics Team

Guide to Monitoring URLs with Authentication Using Splunk AppDynamics and Python

Monitoring URLs are an important part of your FullStackMonitoring.

Splunk AppDynamics lets you monitor URLs with different authentication. In this article, we will create a simple URL with a username and password. Afterwards, we will monitor it using AppDynamics Machine Agent.

Create a Simple API with Python (Flask)

  1. Install Flask:
    pip install flask​
  2. Create the API: Save the following Python code to a file, e.g., basic_auth_api.py:
    from flask import Flask, request, jsonify
    from flask_httpauth import HTTPBasicAuth
    
    app = Flask(__name__)
    auth = HTTPBasicAuth()
    
    # Dummy users for authentication
    users = {
        "user1": "password123",
        "user2": "securepassword",
    }
    
    @auth.get_password
    def get_pw(username):
        return users.get(username)
    
    @app.route('/api/data', methods=['GET'])
    @auth.login_required
    def get_data():
        return jsonify({"message": f"Hello, {auth.username()}! Here is your data."})
    
    if __name__ == '__main__':
        app.run(debug=True, port=5000)
  3. Run the API: Start the server by running:
    python basic_auth_api.py
  4. Test the API: Use curl to access the API:
    curl -u user1:password123 http://127.0.0.1:5000/api/data
  5. You should see a response like this:
    {
        "message": "Hello, user1! Here is your data."
    }​
    Screenshot 2025-01-16 at 6.58.33 PM.png

Install Machine Agent

You can install the Machine agent as recommended here

Setup URL Monitoring Extension

  1. Clone the Github Repo:
    git clone https://github.com/Appdynamics/url-monitoring-extension.git​
    cd url-monitoring-extension​
  2. Download and install Apache Maven which is configured with Java 8 to build the extension artifact from the source.
    You can check the Java version used in Maven using command
     mvn -v or mvn --version.
    If your maven is using some other Java version then please download Java 8 for your platform and set JAVA_HOME parameter before starting maven. Run below in url-monitoring-extension directory
    mvn clean install
  3. Go into the target directory and copy the UrlMonitor-2.2.1.zip, Afterwards unzip the content inside <MA-Home>/monitors/folder
    cd target/
    mv UrlMonitor-2.2.1.zip /opt/appdynamics/machine-agent/monitors
    unzip UrlMonitor-2.2.1.zip​
  4. This will create an UrlMonitor directory inside the Monitors folder.

Monitor the URL

  1. Inside the UrlMonitor folder, edit the config.yml file
  2. Under sites, I have added:
    sites:
      - name:     AppDynamics
        url:      http://127.0.0.1:5000/api/data
        username: user1
        password: password123
        authType: BASIC​
  3. Change:
    metricPrefix: "Custom Metrics|URL Monitor|"​
  4. Now, All you need to do is Start your Machine Agent again.
  5. Afterward, you can see this URL monitor in your AppDynamics Controller.Screenshot 2025-01-16 at 7.08.50 PM.png
Version history
Last update:
‎01-16-2025 10:06 AM
Updated by:
Now On Demand
Learn how Splunk and AppDynamics are redefining observability


Watch Now!

Observe and Explore
Dive into our Community Blog for the Latest Insights and Updates!


Read the blog here