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

Start OneAgent in off mode

Ellery
Helper

Hello dear community, I turn to your infinite wisdom for guidance. I have some Kubernetes clusters in a QA environment that are turned off every night and turned on the next day. I have Dynatrace installed on these clusters, but I generally use it on-demand. The problem occurs every morning when the clusters are turned on, they come up with a new name and this causes the configuration I left the day before (turning off One-agent monitoring) to be lost and One-agent to start in ON mode.

Is it possible or is there any configuration in the One-agent installation that starts in OFF monitoring mode?

I appreciate your help.

 

Ellery_0-1720615782713.png

 

7 REPLIES 7

Julius_Loman
DynaMight Legend
DynaMight Legend

We have developed an extension 2.0 which allows you to define profiles and sets one agent modes accordingly to the profile for new connected OneAgents. If you are interested, reach out to me here in the thread.

With Kubernetes it also depends on your deployment mode. 

 

This can be also accomplished by workflows - if you are on SaaS.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

We are currently using the DPS and SaaS model. The installation was done with HELM and with the dynakube.yaml file that Dynatrace suggests in its installation guide. Is it not possible to set monitoring=off in dynakube.yaml or something similar to make it start up turned off?

No, oneagents (either full stack or pass) cannot be started deactivated. You can always deactivate and reactivate them using Settings API. That's exactly what we are doing with the extension.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Thank you for your help. How can I enable or disable monitoring with OneAgent on Kubernetes using the extension you mentioned?

 

Thank you very much

@Ellery our extension allows you to configure newly connected OneAgents and disable them or switch the monitoring mode according to the defined rules, I think the screenshot says it all.

Julius_Loman_0-1725949566153.png

 

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

PierreGutierrez
Dynatrace Pro
Dynatrace Pro

Hi @Ellery 

I understand your problem, however I think it can be solved by configuring the Process Group, Services Name rules, Container rules, Host naming 💪.


My best recommendation is that you evaluate those rules and your problem could be solved 😄
I hope its help 💪

Pierre Gutierrez - LATAM ACE Consultant - Loving Cats! Loving Technology !

Ellery
Helper

I found the solution in a workflow, and using JavaScript, we search for each monitored host, filter them based on the pattern we need, and then shut them down. Here's the code.

var https://{environmentid}.live.dynatrace.com/api/v2/";
//const request = require('request');
const schemaIds = "builtin:host.monitoring"


var api_token_entities = "<token TOKEN READ WRITTE ENTITIES>"; 
var api_token =  "<TOKEN ONEAGENT - READ - WRITTE>";
// Step 1: Get all Object Ids for HOST schema
const options = {
  method: 'GET',
  headers: {
    'Authorization': `Api-Token ${api_token}`
  }
};

const disable_host_group = ["qa-xxxxxx", "qa-yyyyyyy", "qa-ddddddd",  "qa-sssssssss"]

https://{environmentid}.live.dynatrace.com/api/v1/oneagents`, options, (response) => {     

    let data = '';
  
  response.on('data', (chunk) => {
    data += chunk;
  });

  response.on('end', () => {
    const hostObjects = JSON.parse(data);
    if ("error" in hostObjects) {
      console.log(`Error occurred: ${hostObjects.error.message}`);
      process.exit(1);
    }

    const hosts = hostObjects["hosts"]

    Object.keys(hosts).forEach(key => {

      var cluster = hosts[key]["hostInfo"]["kubernetesCluster"];
      var estado = hosts[key]["availabilityState"];
      var entityID = hosts[key]["hostInfo"]["entityId"];
      
      try {
        var hostgroupID = hosts[key]["hostInfo"]["hostGroup"]["meId"];
      } catch (error) {
        var hostgroupID = "nulo";
      }

      try {
        var hostGroup = hosts[key]["hostInfo"]["hostGroup"]["name"];
      } catch (error) {
        var hostGroup = "nulo";
      }
     
      if(disable_host_group.includes(hostGroup)) {
        if(estado == "MONITORED"){
          console.log(key + " " + entityID + " ---> " + cluster + " ---> " + estado + " ---> " + hostgroupID + " ---> " + hostGroup );
          update(entityID);
        }
      }
    });
  
  });
 
  
}).on("error", (error) => {
  console.error(`Error: ${error.message}`);
});   


// Configura las opciones para la solicitud

function update(host) {

    console.log("inicio actualizacion : " + host)

  const options_update = {
    hostname: '<tenantdyantrace>.live.dynatrace.com',
    port: 443,
    path: '/api/v2/settings/objects/?scope='+host,
    method: 'POST',
    headers: {
      'Accept': 'application/json; charset=utf-8',
      'Content-Type': 'application/json; charset=utf-8',
      'Authorization': `Api-Token ${api_token_entities}`
    }
  };
    
  // make the petition
  const req_update = https.request(options_update, (res) => {
    let data1 = '';
  
    // Reception the data
    res.on('data1', (chunk) => {
      data1 += chunk;
    });
  
    // when the answere end, process data
    res.on('end', () => {
      //console.info('Response:', data1);
    });
  });
  
  // error management
  req_update.on('error', (e) => {
    console.error('Error:', e.message);
  });
  
  // send data
  const postData = JSON.stringify([{
    "schemaId": "builtin:host.monitoring",
    "scope": host,
    "value": { "enabled": false }
  }]);
  
  req_update.write(postData);
  req_update.end();

      console.log("update end: " + host)

}

i hope this solution can help somebody

Featured Posts