cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to turn OneAgent ON or OFF on a specific host via the REST API

DuaneRoelands
Contributor

I want to turn OneAgent ON or OFF on a specific host via the REST API, but I can't find the specific endpoint to do this.  The OneAgent API seems to be read-only.

I am able to get a list of OneAgents from the API, and by searching the response for my server name, I can find the entityID.   What endpoint in the REST API can I use to turn OneAgent off on that server?

This is for DynaTrace SaaS.

8 REPLIES 8

Yosi_Neuman
DynaMight Guru
DynaMight Guru

Hi @DuaneRoelands 

Once upon a time we used OneAgent monitoring configuration API - PUT configuration but this API is deprecated.

 

Yosi_Neuman_1-1690482810621.png

In order to use the current v2 setting api please go to the setting page of your host under setting --> host monitoring , use the ... on the right corner

Yosi_Neuman_2-1690483128768.png

in order to open the menu 

Yosi_Neuman_3-1690483162689.png

and choose api

Yosi_Neuman_4-1690483227305.png

just copy the update api call and you are all set! 

HTH

Yos

 

dynatrace certificated professional - dynatrace master partner - Matrix Soft Ware Division - Israel

DuaneRoelands
Contributor

This does not work.

Submitted this payload (taken from the API section of the settings as you instructed:

{"schemaId":"builtin:host.monitoring","schemaVersion":"1.2.1","scope":"HOST-29200A0CBEF971B4","value":{"enabled":true,"autoInjection":true}}

 

 

 
Got error 400, "constraints violated",  path "setting must not be null".
 
I would post the full JSON of the response, but the forum software flags it as invalid HTML and won't let me post it.

 

 

Hi @DuaneRoelands. Please add [] in the payload.

The true delight is in the finding out rather than in the knowing.

DuaneRoelands
Contributor

This doesn't work, either.

Payload: 

[{"schemaId":"builtin:host.monitoring","schemaVersion":"1.2.1","scope":"HOST-29200A0CBEF971B4","value":{"enabled":true,"autoInjection":true}}]
 
Response:
{
    "error": {
        "code"400,
        "message""Could not map JSON at '' near line 1 column 1"
    }
}
 
Please don't accept solutions that haven't been validated.

 

Hi @DuaneRoelands 

Use POST method in the following API:

{{baseUrl}}/settings/objects?validateOnly=true

and change baseUrl placeholder for your tenant/api/v2

then your payload

[
  {
    "schemaId": "builtin:host.monitoring",
    "value": {
                "enabled": true,
                "fullStack": false,
                "autoInjection": true
            },
    "schemaVersion": "1.2.1",
    "scope": "HOST-29200A0CBEF971B4"
  }
]

 

if everything goes right you should receive a

[
    {
        "code": 200
    }
]

 

The true delight is in the finding out rather than in the knowing.

Still not working.

Endpoint:

/api/v2/settings/objects?validateOnly=true

Body: 

[
  {
    "schemaId""builtin:host.monitoring",
    "value": {
                "enabled"true,
                "fullStack"false,
                "autoInjection"true
            },
    "schemaVersion""1.2.1",
    "scope""HOST-29200A0CBEF971B4"
  }
]
 
Response:
[
    {
        "code"400,
        "error": {
            "code"400,
            "message""Validation failed for 1 Validators.",
            "constraintViolations": [
                {
                    "path""builtin:host.monitoring/0/fullStack",
                    "message""Given property 'fullStack' with value: 'false' was not found in the schema",
                    "parameterLocation""PAYLOAD_BODY",
                    "location"null
                }
            ]
        },
        "invalidValue": {
            "enabled"true,
            "fullStack"false,
            "autoInjection"true
        }
    }
]
 

 

Hi @DuaneRoelands set schema to:

    "schemaVersion": "1.2.0",

 this should work. Could be a bug on the API.

I query the schema and it is correct:

        {
            "schemaId": "builtin:host.monitoring",
            "displayName": "Monitoring",
            "latestSchemaVersion": "1.2.1"
        }
The true delight is in the finding out rather than in the knowing.

Changing the schema version to 1.2.0 worked.  Thank you for your assistance!

Featured Posts