Skip to content

Commit

Permalink
Adding dist for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Betancur committed Oct 13, 2022
1 parent e2a714f commit bdea686
Show file tree
Hide file tree
Showing 36 changed files with 1,790 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
package-lock.json
dist
grafana-plugins
30 changes: 30 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# New Relic APM Datasource - Custom Plugin
This is a simple datasource for use with the New Relic APM API.

## Major Update Notice
This datasource plugin has been converted to a full app plugin to allow for more secure handling of
new relic API keys. If you have previously used the old datasource plugin version, you will need to
configure this application with your api key, and then create a new datasource.

## Supported Version Information
This datasource has been tested with 4.2 stable.

## To install and use

1. Add the contents of this repository to your grafana plugins directory (default /var/lib/grafana/plugins) and then restart the grafana server.

2. Create a new app and configure it with your API key

2. Create a new datasource and select NewRelic from the drop down.

3. Create a new panel and set the datasource to NewRelic. Metrics take a namespace and optional value configuration. The namespaces must be exact match of the metric name, which can be found for your application [here](https://rpm.newrelic.com/api/explore/applications/metric_names)

This datasource supports aliases and altering the group by interval.
![Alias](http://i.imgur.com/sV0bEoA.png)

If you leave the value field blank, you will get a separate group for each value of the metric. You can access the value as $value in the alias.

## Build
npm install
npm install -g grunt-cli
grunt
14 changes: 14 additions & 0 deletions dist/config/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// <reference path="../typings/tsd.d.ts" />
export declare class NewRelicAppConfigCtrl {
private backendSrv;
appModel: any;
appEditCtrl: any;
jsonData: any;
apiValidated: boolean;
apiError: boolean;
constructor($scope: any, $injector: any, backendSrv: any);
preUpdate(): Promise<void>;
reset(): void;
validateApiConnection(): any;
static templateUrl: string;
}
24 changes: 24 additions & 0 deletions dist/config/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<h3 class="page-heading">New Relic API Credentials</h3>

<div class="gf-form-group">
<div class="gf-form-inline">
<div class="gf-form">
<label class="gf-form-label width-7">API Key</label>
<info-popover mode="right-absolute">
The API key generated for authorization in the APM dashboard.
</info-popover>
<!-- Hidden input to stop chrome from autofilling -->
<input style="display:none;" type="password" name="anotherfakename" />
<input type="password" class="gf-form-input width-20" ng-model="ctrl.appModel.secureJsonData.apiKey" ng-if="!ctrl.appModel.jsonData.tokenSet" placeholder="api key"/>
</div>
<div ng-if="ctrl.appModel.jsonData.tokenSet" class="gf-form">
<input type="text" class="gf-form-input width-20" disabled="disabled" value="saved" />
<div ng-if="ctrl.appModel.enabled">
<i class="fa fa-exclamation-triangle" ng-if="!ctrl.apiValidated" alt="Could not validate api Token."></i>
</div>
</div>
<div class="gf-form">
<a class="btn btn-danger" href="#" ng-click="ctrl.reset()" ng-if="ctrl.appModel.jsonData.tokenSet">reset</a>
</div>
</div>
</div>
52 changes: 52 additions & 0 deletions dist/config/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/config/config.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions dist/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
///<reference path="../typings/tsd.d.ts" />

export class NewRelicAppConfigCtrl {
appModel: any;
appEditCtrl: any;
jsonData: any;
apiValidated: boolean;
apiError: boolean;

constructor($scope, $injector, private backendSrv) {
this.backendSrv = backendSrv;
console.log(this);

this.appEditCtrl.setPreUpdateHook(this.preUpdate.bind(this));

if (!this.appModel.jsonData) {
this.appModel.jsonData = {};
}
if (!this.appModel.secureJsonData) {
this.appModel.secureJsonData = {};
}

if (this.appModel.enabled && this.appModel.jsonData.tokenSet) {
this.validateApiConnection();
}
}

preUpdate() {
if (this.appModel.secureJsonData.apiKey) {
this.appModel.jsonData.tokenSet = true;
}
return Promise.resolve();
}

reset() {
this.appModel.jsonData.tokenSet = false;
this.appModel.secureJsonData = {};
this.apiValidated = false;
}

validateApiConnection() {
var promise = this.backendSrv.get('/api/plugin-proxy/newrelic-app/v2/applications.json');
promise.then(() => {
this.apiValidated = true;
}, () => {
this.apiValidated = false;
this.apiError = true;
});
return promise;
}

static templateUrl = 'config/config.html';
}
12 changes: 12 additions & 0 deletions dist/datasource/config_ctrl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path="../typings/tsd.d.ts" />
export declare class NewRelicDSConfigCtrl {
private backendSrv;
static templateUrl: string;
name: string;
current: any;
types: any;
apps: any[];
constructor($scope: any, $injector: any, backendSrv: any);
getApplications(): any;
loadApplications(): void;
}
40 changes: 40 additions & 0 deletions dist/datasource/config_ctrl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/datasource/config_ctrl.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions dist/datasource/config_ctrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
///<reference path="../typings/tsd.d.ts" />

export class NewRelicDSConfigCtrl {
static templateUrl = 'datasource/partials/config.html';
name: string;
current: any;
types: any;
apps: any[];

constructor($scope, $injector, private backendSrv) {
this.backendSrv = backendSrv;
this.loadApplications();
}

getApplications() {
var promise = this.backendSrv.get('api/plugin-proxy/newrelic-app/v2/applications.json');
return promise.then(result => {
if (result && result.applications) {
return result.applications;
} else {
return [];
}
});
}

loadApplications() {
this.getApplications().then(apps => {
apps = apps.map(app => {
return { name: app.name, id: app.id.toString() };
});
this.apps = apps;
});
}

}
23 changes: 23 additions & 0 deletions dist/datasource/datasource.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// <reference path="../typings/tsd.d.ts" />
declare class NewRelicDatasource {
private $q;
private backendSrv;
private templateSrv;
name: string;
appId: any;
baseApiUrl: string;
/** @ngInject */
constructor(instanceSettings: any, $q: any, backendSrv: any, templateSrv: any);
query(options: any): Promise<{}>;
testDatasource(): any;
_convertToSeconds(interval: any): number;
_parseMetricResults(results: any): any[];
_parseseacrhTarget(metric: any): any[];
_getTargetSeries(target: any, metric: any): any[];
_parseTargetAlias(metric: any, value: any): any;
makeMultipleRequests(requests: any): Promise<{}>;
getMetricNames(application_id: any): any;
getApplications(value?: number, extResult?: any[]): any;
makeApiRequest(request: any): any;
}
export { NewRelicDatasource };
Loading

0 comments on commit bdea686

Please sign in to comment.