Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appmetrics-elk

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appmetrics-elk - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

44

lib/appmetrics-elk.js

@@ -16,6 +16,23 @@ /*******************************************************************************

*******************************************************************************/
var os = require('os');
var INDEX = 'appmetrics';
var APPNAME = process.argv[1];
var HOSTNAME = os.hostname();
var PID = process.pid;
var monitor = function (opts) {
var appmetrics = require('appmetrics');
var monitor = appmetrics.monitor();
if (typeof(opts) !== 'undefined') {
if (typeof(opts.index) !== 'undefined') {
INDEX = opts.index;
delete opts.index;
}
if (typeof(opts.applicationName) !== 'undefined') {
APPNAME = opts.applicationName;
delete opts.applicationName;
}
}

@@ -31,9 +48,9 @@ var elasticsearch = require('elasticsearch');

esearch.indices.exists({
'index': 'appmetrics'
'index': INDEX
}, function (err, res){
if (res === false) {
esearch.indices.create({
'index': 'appmetrics'
'index': INDEX
}, function (err, res) {
putMappings(esearch, 'appmetrics');
putMappings(esearch, INDEX);
});

@@ -61,3 +78,3 @@ }

/*
* Check to see if there are any Kibana index format mappings for appmetrics, if not:
* Check to see if there are any Kibana index format mappings for the index, if not:
* 1) Set the index format mappings

@@ -70,3 +87,9 @@ * 2) Upload default charts

type : 'index-pattern',
id: 'appmetrics'
body: {
query: {
match: {
_id: INDEX
}
}
}
}, function (err, res) {

@@ -177,3 +200,3 @@ if (!res.exists === true) {

esearch.bulk({
index: 'appmetrics',
index: INDEX,
body: bulkarray

@@ -199,2 +222,3 @@ }, function (err, rep) {

getJSONfromDir('configs', function (config) {
config.body.defaultIndex = INDEX;
esearch.index(config, function (err, res) {

@@ -212,2 +236,4 @@ if (err) {

getJSONfromDir('indexes', function (index) {
index.id = INDEX;
index.body.title = INDEX;
esearch.index(index, function (err, res) {

@@ -237,2 +263,3 @@ if (err) {

getJSONfromDir('charts', function (chart) {
chart.body.kibanaSavedObjectMeta.searchSourceJSON = chart.body.kibanaSavedObjectMeta.searchSourceJSON.replace('appmetrics', INDEX);
esearch.index(chart, function (err, res) {

@@ -251,6 +278,2 @@ if (err) {

var os = require('os');
var HOSTNAME = os.hostname();
var PID = process.pid;
function Entry(type, time) {

@@ -260,2 +283,3 @@ this.timestamp = new Date(time);

this.pid = PID;
this.applicationName = APPNAME;
this[String(type)] = {};

@@ -262,0 +286,0 @@ }

@@ -8,5 +8,6 @@ {

"properties": {
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"applicationName": {"type": "string", "index": "not_analyzed"},
"cpu": {

@@ -13,0 +14,0 @@ "type": "nested",

@@ -8,5 +8,6 @@ {

"properties": {
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"applicationName": {"type": "string", "index": "not_analyzed"},
"gc": {

@@ -13,0 +14,0 @@ "type": "nested",

@@ -8,5 +8,6 @@ {

"properties": {
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"applicationName": {"type": "string", "index": "not_analyzed"},
"http": {

@@ -13,0 +14,0 @@ "type": "nested",

@@ -8,5 +8,6 @@ {

"properties": {
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"applicationName": {"type": "string", "index": "not_analyzed"},
"memory.process" : {

@@ -13,0 +14,0 @@ "type": "nested",

@@ -8,5 +8,6 @@ {

"properties": {
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"applicationName": {"type": "string", "index": "not_analyzed"},
"mongo": {

@@ -13,0 +14,0 @@ "type": "nested",

@@ -8,5 +8,6 @@ {

"properties": {
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"timestamp": {"type": "date", "format": "dateOptionalTime"},
"hostName": {"type": "string", "index": "not_analyzed"},
"pid": {"type": "integer"},
"applicationName": {"type": "string", "index": "not_analyzed"},
"mysql": {

@@ -13,0 +14,0 @@ "type": "nested",

{
"name": "appmetrics-elk",
"version": "1.0.0",
"version": "1.0.1",
"description": "ELK Connector for Node Application Metrics",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -28,2 +28,7 @@ # ELK Connector for Node Application Metrics

Additionally, the `monitor()` API call can be passed an optional [ElasticSearch Configuration][3] object to configure the ElasticSearch connection, including database location and security.
The same configuration object can be used to pass configuration to the ELK connector. The following configurations can be applied:
* `index` (String) the name of the index to use for storing the monitoring data. The default is `appmetrics`.
* `applicationName` (String) the name to use for the applicationName field in the monitoring data. The default is the name of the applications main file, eg. `app.js`.
```js

@@ -38,3 +43,5 @@ var config = {

rejectUnauthorized: true
}
},
index: 'nodedata',
applicationName: 'HelloWorld'
}

@@ -55,2 +62,3 @@

pid | The process ID for the monitored process
applicationName | The JavaScript file used to launch the application, or a custom name

@@ -179,6 +187,9 @@ Additional data is then included depending on the monitoring event.

### Version
1.0.0
The current version is 1.0.1
1.0.1 Support for configurable indexes and addition of applicationName field
1.0.0 Initial release
[1]:https://www.elastic.co/downloads/elasticsearch
[2]:https://www.elastic.co/downloads/kibana
[3]:https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc