@dynatrace/api-client
A NodeJS package for the Dynatrace REST API
Last updated 25 days ago by beeme1mr .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @dynatrace/api-client 
SYNC missed versions from official npm registry.

Dynatrace API Module

Welcome to the Dynatrace Api node module. This is a simple helper module for interacting with the Dynatrace API including caching support.

Disclaimer

This plugin is community contributed and not officially supported by Dynatrace. In case of problems, feature requests, or questions submit a ticket on GitHub .

Requirements

  • Dynatrace SaaS or Managed environment
  • API key from Dynatrace environment
  • Minimum node version 6.10

Basic Usage

Problem Feed and Details

const { Dynatrace } = require("@davis/dynatrace");
const redis = require("redis").createClient();

const dynatrace = new Dynatrace({
  baseUrl: "https://base-url-of-dynatrace-server",
  apiToken: "api-token-of-dynatrace-server",
  redis: redis, // this is optional
  cacheTTL: 600, // defaults to 60. Time to cache entities in seconds
  cachePrefix: "davis-redis-cache" // prefix for redis keys to prevent collisions
});

dynatrace
  .problemFeed({
    relativeTime: "day"
  })
  .then(problems => {
    // Full list of problems here
    console.log(`There were ${problems.length} problems in the last day.`);
    // There were 191 problems in the last day.
    return problems[0];
  })
  .then(problem => {
    // single problem here
    console.log(
      `The first problem is a ${problem.status} ${problem.impactLevel} problem`
    );
    // The first problem is a CLOSED APPLICATION problem
    return problem.getDetails();
  })
  .then(details => {
    // more detailed problem information here
    console.log(`with ${details.commentCount} comments.`);
    // with 0 comments.

    return details.addComment({
      content: "Checked using the dynatrace nodejs client",
      username: "@cto",
      context: "nodejs client"
    });
  });

Timeseries

dynatrace
  .applications({ tag: "davis" })
  .then(apps => _.find(apps, a => a.displayName === "Davis"))
  .then(davis => {
    return davis.userActionDurationXHR({
      queryMode: "total",
      relativeTime: "day"
    });
  })
  .then(data => {
    console.log(util.inspect(data, null, null));
  });

// ​​​​​{ dataPoints: ​​​​​
// ​​​​​   { 'APPLICATION-7D7CBD136E0B9959': [ [ 1520351760000, 423683.00326322095 ] ] },​​​​​
// ​​​​​  timeseriesId: 'com.dynatrace.builtin:app.useractionduration.xhr',​​​​​
// ​​​​​  unit: 'MicroSecond (µs)',​​​​​
// ​​​​​  entities: { 'APPLICATION-7D7CBD136E0B9959': 'Davis' },​​​​​
// ​​​​​  resolutionInMillisUTC: 86400000,​​​​​
// ​​​​​  aggregationType: 'AVG' }​​​​​

Deployments

Deploy An Application

async function deploy(entityId) {
  const deployment = dynatrace.startDeployment({
    deploymentName: "Test deployment",
    deploymentProject: "dynatrace node module",
    deploymentVersion: "0.0.1-7",
    source: "dynatrace node module"
  });

  // helpers for setting API parameters
  deployment.attachRules({ entityIds: [entityId] });

  // Deployment things here

  deployment.ciBackLink("https://link-to-ci");
  return deployment.send();
}

Get Deployments

async function deployments(entityId) {
  dynatrace
    .applications()
    .then(apps => apps[0])
    .then(app => app.deployments())
    .then(console.log);
}

Timeseries

dynatrace
  .applications()
  .then(apps => apps[0])
  .then(app =>
    app.userActionsPerMinute({
      relativeTime: "2hours",
      queryMode: "total",
      aggregationType: "avg"
    })
  );

Current Tags

  • 2.16.5                                ...           latest (25 days ago)

42 Versions

  • 2.16.4 [deprecated]           ...           25 days ago
  • 2.16.5                                ...           25 days ago
  • 2.16.3                                ...           6 months ago
  • 2.16.2                                ...           a year ago
  • 2.16.1                                ...           a year ago
  • 2.16.0                                ...           a year ago
  • 2.15.0                                ...           a year ago
  • 2.14.0                                ...           a year ago
  • 2.13.0                                ...           a year ago
  • 2.11.5                                ...           a year ago
  • 2.11.4                                ...           a year ago
  • 2.11.3                                ...           a year ago
  • 2.11.2                                ...           a year ago
  • 2.11.1                                ...           a year ago
  • 2.11.0                                ...           a year ago
  • 2.10.0                                ...           a year ago
  • 2.9.0                                ...           a year ago
  • 2.8.0                                ...           a year ago
  • 2.7.1                                ...           a year ago
  • 2.7.0                                ...           a year ago
  • 2.6.3                                ...           a year ago
  • 2.6.2                                ...           a year ago
  • 2.6.1                                ...           a year ago
  • 2.6.0                                ...           a year ago
  • 2.5.4                                ...           a year ago
  • 2.5.3                                ...           a year ago
  • 2.5.2                                ...           a year ago
  • 2.5.1                                ...           a year ago
  • 2.5.0                                ...           a year ago
  • 2.4.1                                ...           a year ago
  • 2.4.0                                ...           a year ago
  • 2.3.0                                ...           a year ago
  • 2.2.0                                ...           a year ago
  • 2.1.5                                ...           a year ago
  • 2.1.4                                ...           a year ago
  • 2.1.3                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 71
Dependencies (5)
Dev Dependencies (20)

Copyright 2014 - 2016 © taobao.org |