浏览代码

update README
update default counters table name

Nicolas FRADIN 12 年之前
父节点
当前提交
9a2922d58b
共有 4 个文件被更改,包括 22 次插入11 次删除
  1. 19 8
      README.md
  2. 1 1
      countersEngine.js
  3. 1 1
      mysql-backend.js
  4. 1 1
      tables/statistics.sql

+ 19 - 8
README.md

@@ -34,16 +34,27 @@ Example :
 
 Required parameters :
 
-* host:	MySQL instance host.
-* port:	MySQL instance port.
-* user:	MySQL user.
-* password: MySQL password.
-* database:	Default database where statsd table are stored.
+* `host`: MySQL instance host.
+* `port`: MySQL instance port. 
+* `user`: MySQL user.
+* `password`: MySQL password.
+* `database`: Default database where statsd table are stored.
 
 Optional parameters :
 
-*tables:		List of tables names used (ex: ["stats", "users"]).
-*engines:	List of MySQL Backend engines (see 'MySQL Bakend Engines' chapter for more details).
+* `tables`: List of tables names used (ex: ["stats", "users"]).
+* `engines`: List of MySQL Backend engines (see 'MySQL Bakend Engines' chapter for more details).
 
 
-## Introduction
+## Introduction
+This is node.js backend for statsd. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.
+
+It save statsd received values to a MySQL database.
+
+## Data Structure for statsd counters
+By default, values are stored into a 'counters_statistics' table. This table has a very simple structure with 3 columns :
+* `timestamp`: The timestamp sent by statsd flush event
+* `name`: The counter name
+* `value`: The counter value
+The primary key of this table is composed by fields: timestamp and name. It means when a new value arrives for a counter, this value is added to the previous one and stored in database. With this mechanism, we can keep a log of counters values.
+

+ 1 - 1
countersEngine.js

@@ -20,7 +20,7 @@ MySQLBackendCountersEngine.prototype.buildQuerries = function(userCounters, time
       if(counterValue === 0) {
         continue;
       } else {
-        querries.push("insert into `statistics` (`timestamp`,`name`,`value`) values(" + time_stamp + ",'" + escape(userCounterName) +"'," + counterValue + ") on duplicate key update value = value + " + counterValue + ", timestamp = " + time_stamp);
+        querries.push("insert into `counters_statistics` (`timestamp`,`name`,`value`) values(" + time_stamp + ",'" + escape(userCounterName) +"'," + counterValue + ") on duplicate key update value = value + " + counterValue + ", timestamp = " + time_stamp);
       }
     }
 

+ 1 - 1
mysql-backend.js

@@ -59,7 +59,7 @@ function StatdMySQLBackend(startupTime, config, emitter) {
 
   //Default tables
   if(!this.config.tables) {
-    this.config.tables = ["statistics"];
+    this.config.tables = ["counters_statistics"];
   }
 
   // Default engines

+ 1 - 1
tables/statistics.sql

@@ -1,4 +1,4 @@
-CREATE  TABLE `statsd_db`.`statistics` (
+CREATE  TABLE `statsd_db`.`counters_statistics` (
     `timestamp` BIGINT NOT NULL ,
     `name` VARCHAR(255) NOT NULL ,
     `value` VARCHAR(45) NOT NULL ,