How to Disable Policies via the API Developer Guide

Learn how to turn policies on and off through the API.

You can use the Metricly CLI or interact directly with the Metricly API to manipulate policies. A common need from some of our users is to temporarily disable their policies while building, testing, or modifying them. This short guide walks you through how to do that via the Policy API directly.

1. Get Policy ID.

  1. In Metricly, navigate to the policy you want to edit.
  2. Copy the policy’s ID from the url.

2. Get & Put the Policy Document via Swagger

  1. GET from /policies/getPolicyUsingGET
    {
      "policy": {
        "id": "12345a123-ab12-12345-bc12-23456a78",
        "name": "RabbitMQ: Messages in the dead letter queues",
        "description": "RabbitMQ: Messages in the dead letter queues",
        "scope": {
          "elementName": null,
          "elementNameExclude": null,
          "fqnIncludes": [
            "RabbitMQ-Prod-001"
          ],
          "fqnExcludes": [
            
          ],
          "elementType": null,
          "elementTypes": [
            
          ],
          "elementTags": [
            
          ],
          "elementTagsAll": true,
          "excludedElementTags": [
            
          ],
          "elementAttributes": [
            
          ],
          "elementAttributesAll": true,
          "excludedElementAttributes": [
            
          ]
        },
        "duration": 300,
        "conditions": [
          {
            "metric": null,
            "wildcard": "rabbitmq.queues.*(_dl|_dlq).messages",
            "metricScopeTags": {
              
            },
            "analytic": "actual",
            "operator": ">",
            "level": 1,
            "level2": null,
            "metricThresholdLevel": null,
            "metricThresholdAnalytic": null
          }
        ],
        "eventConditions": [
          
        ],
        "checkCondition": null,
        "actions": [
          {
            "type": "event",
            "category": 3
          },
          {
            "type": "notification",
            "id": 12345,
            "enabled": true,
            "notifyFrequencyMin": 1234,
            "sendOnClear": true
          }
        ],
        "enabled": true,
        "deleted": false,
        "creatorEmail": "user.name@username.com",
        "lastUpdated": "2018-06-01T20:32:05Z"
      }
    }
    
  2. Change "enabled": true, to "enabled": false in the policy document.
  3. PUT to /policies/updatePolicyUsingPUT

3.  Done!

You can repeat section 2 to re-enable your policy. Want to make other changes via endpoints? Read more about our Policy API.

capterra

Ready to get started with Metricly?

Sign up for free, and join DevOps who rate us 5-stars on Capterra!

21-day free trial No credit card required