Coder Social home page Coder Social logo

dynatrace-endpoint-evaluator's Introduction

dynatrace-endpoint-evaluator

List endpoints as code and automatically score your webpage health using Dynatrace.

.dynatrace/urls.txt

https://www.dynatrace.com
https://example.com
http://example.com
https://google.com
https://example.com/sitemap.xml
  • URLs ending with sitemap.xml will be "unpacked" and thus include all URLs in the <loc> tag within the sitemap.

Usage

Create Required Secrets

Create 2x GitHub Action secrets called DT_ENVIRONMENT_URL and DT_API_TOKEN.

Where

  • DT_ENVIRONMENT_URL looks like: https://abc12345.live.dynatrace.com
  • DT_ENVIRONMENT_URL looks like: dt0c01.*****.*****

API Token needs these permissions:

  • entities.read (Read entities)
  • ExternalSyntheticIntegration (Create and read synthetic monitors, locations, and nodes)

Create .dynatrace Folder

  1. Create a folder called .dynatrace at the root of your repo
  2. Create a file called config.json in .dynatrace folder
  3. Commit your files to the .dynatrace folder (see supported file formats below)
  4. Add the action to your Git Action workflow

Populate .dynatrace/config.json

This file and these parameters are mandatory.

defaultRootUrl is prepended when only paths are given. If a full URL is given in the input files, this is ignored. This means you can list relative urls and the script will automatically format as defaultRootUrl+YourListedPath. In this case: https://example.com/YourPath.

defaultLocations is an array of GEOLOCATION objects from where you want to run your synthetic tests.

Example .dynatrace/config.json file

{
  "defaultRootUrl": "https://example.com",
  "defaultLocations": ["GEOLOCATION-E01B833216FC3598"]
}

Add Endpoints

Inside .dynatrace create one or more .txt files listing your URLs (one per line) (only plain GET requests are currently supported). Alternatively, place valid sitemap.xml file(s) in this folder. OpenAPI support is a work in progress.

Add Action

Create a workflow in .github/workflows/dynatrace-endpoint-checker.yml

on: [pull_request]

jobs:
  dt_job:
    runs-on: ubuntu-latest
    name: "Check Endpoints with Dynatrace"
    steps:
      # Checkout the repo to the runner
      # This step is mandatory
      - name: Checkout Repo
        uses: actions/checkout@v3
      
      - name: Dynatrace Endpoint Tester
        uses: agardnerIT/[email protected]
        id: dt_job # Mandatory as this is how the comments are pushed to PR
        env:
          dt_environment_url: ${{ secrets.DT_ENVIRONMENT_URL }}
          dt_api_token: ${{ secrets.DT_API_TOKEN }}
          
      - name: Add PR comment
        uses: thollander/actions-comment-pull-request@v1
        with:
          message: |
            ## Endpoint Results
            ${{ steps.dt_job.outputs.table_content }}
          comment_includes: "## Endpoint Results" # Overwrites existing comments (if any). If nothing exists, adds new comment
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Create a PR

  1. Create a new branch and make whatever code changes you require to your code.
  2. Create a new PR and the workflow should automatically trigger.
  3. Adjust the URLs as often as you want in the .dynatrace folder. The PR comment will be updated (avoids PR spam)

Scoring Rules / Logic

Note: If you are looking for a more fully featured page / build / artifact scoring system, I recommend Keptn.

Every endpoint starts at 100% (perfect score). The lowest score possible is obviously zero.

The response time

  • -100%: If a page is missing or has a server-side error (ie. a 4xx or 5xx response)
  • -80%: If page is server over http rather than https
  • -20%: If certificate is due to become invalid within 30 days
  • -10%: If time to first byte (TTFB) is over 800ms
  • -15%: If time to first byte (TTFB) is over 1800ms

If you would like to adjust rules or suggest new ones, please open an issue or PR.

Contributing

Ideas and PRs most welcome!

dynatrace-endpoint-evaluator's People

Contributors

agardnerit avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.