1.0.6 • Published 5 years ago

skybase-stat v1.0.6

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

skybase-stat 相关API统计系统

安装依赖

$ npm i

本地配置设置 - ./config/config.local.js

module.exports = {
    redis: {
        host: 'localhost',
        port: 6379,
        auth: '',
        db: 1
    },
    redisStack: {
        host: 'localhost',
        port: 6379,
        auth: '',
        db: 2
    },
    stackRabbitMQ: { // 可选
        protocol: 'amqp',
        host: 'localhost',
        port: '5672'
    }
}

启动项目

$ node index.js

访问相应api

http://localhost:13000/skyapi/getAll?type=mix
http://localhost:13000/skyapi/getOne?api=_skyapi_getAll&type=chart
http://localhost:13000/skyapi/getSpecialKeys?keyList=["api:_skyapi_getAll"]&count5m=1&count1h=1&count1d=1

获取所有统计

获取所有接口调用总数,每个接口1h的count执行最长max时长 执行min时长 avg时长

地址/skyapi/getAll

方法GET

query参数

参数名必须类型默认值说明
typestring默认:api输出类型 api-输出输出 mix-html输出直接输出html界面

200返回说明

{
  "data": {
    "_skyapi_getAll": {
      "count": 0,
      "max": "0 ms",
      "min": "0 ms",
      "avg": "0 ms"
    },
    "_skyapi_getSome": {
      "count": 0,
      "max": "0 ms",
      "min": "0 ms",
      "avg": "0 ms"
    },
    "_skyapi_getOne": {
      "count": 2,
      "max": "30 ms",
      "min": "15 ms",
      "avg": "22.5 ms"
    },
    "_skyapi_getSpecialKeys": {
      "count": 4,
      "max": "35 ms",
      "min": "5 ms",
      "avg": "16.25 ms"
    }
  },
  "code": 200,
  "msg": "成功",
  "t": 1561964915613
}

获取某几个统计

获取指定列表中 api1h同getAll一样的数据

地址/skyapi/getSome

方法GET

query参数

参数名必须类型默认值说明
apiListstring默认:无输出api列表名称 jsonStr输出api列表名称 jsonStr 例:"_test", "_test1_test2"
typestring默认:api输出类型 api-输出输出 mix-html输出直接输出html界面

200返回说明

{
  "data": {
    "_skyapi_getAll": {
      "count": 0,
      "max": "0 ms",
      "min": "0 ms",
      "avg": "0 ms"
    },
    "_skyapi_getSome": {
      "count": 0,
      "max": "0 ms",
      "min": "0 ms",
      "avg": "0 ms"
    },
    "_skyapi_getOne": {
      "count": 2,
      "max": "30 ms",
      "min": "15 ms",
      "avg": "22.5 ms"
    },
    "_skyapi_getSpecialKeys": {
      "count": 4,
      "max": "35 ms",
      "min": "5 ms",
      "avg": "16.25 ms"
    }
  },
  "code": 200,
  "msg": "成功",
  "t": 1561964915613
}

获取单个统计

获取指定api 5m 24个点,1h 24个点,1d 30个点

地址/skyapi/getOne

方法GET

query参数

参数名必须类型默认值说明
apistring默认:无api名称指定api名称 例: _test
typestring默认:api输出类型 api-输出输出 mix-html输出 chart-html只有图表直接输出html界面

200返回说明

{
  "data": {
    "5m": {
      "count": {
        "step": 300000,
        "unitType": "m",
        "data": [
          [
            1561964700000,
            1
          ]
        ]
      },
      "max": {
        "step": 300000,
        "unitType": "m",
        "data": [
          [
            1561964700000,
            8
          ]
        ]
      },
      "min": {
        "step": 300000,
        "unitType": "m",
        "data": [
          [
            1561964700000,
            8
          ]
        ]
      },
      "avg": {
        "step": 300000,
        "unitType": "m",
        "data": [
          [
            1561964700000,
            8
          ]
        ]
      }
    },
    "1h": {
      "count": {
        "step": 3600000,
        "unitType": "h",
        "data": [
          [
            1561964400000,
            1
          ]
        ]
      },
      "max": {
        "step": 3600000,
        "unitType": "h",
        "data": [
          [
            1561964400000,
            8
          ]
        ]
      },
      "min": {
        "step": 3600000,
        "unitType": "h",
        "data": [
          [
            1561964400000,
            8
          ]
        ]
      },
      "avg": {
        "step": 3600000,
        "unitType": "h",
        "data": [
          [
            1561964400000,
            8
          ]
        ]
      }
    },
    "1d": {
      "count": {
        "step": 86400000,
        "unitType": "d",
        "data": [
          [
            1561910400000,
            9
          ]
        ]
      },
      "max": {
        "step": 86400000,
        "unitType": "d",
        "data": [
          [
            1561910400000,
            20
          ]
        ]
      },
      "min": {
        "step": 86400000,
        "unitType": "d",
        "data": [
          [
            1561910400000,
            4
          ]
        ]
      },
      "avg": {
        "step": 86400000,
        "unitType": "d",
        "data": [
          [
            1561910400000,
            7.111111111111111
          ]
        ]
      }
    }
  },
  "code": 200,
  "msg": "成功",
  "t": 1561964994648
}

获取指定几个key相应数据

获取指定几个key相应数据 5m 24个点,1h 24个点,1d 30个点

地址/skyapi/getSpecialKeys

方法GET

query参数

参数名必须类型默认值说明
keyListstring默认:无输出key列表名称 jsonStr输出key列表名称 jsonStr 例:"_test", "_test1_test2"
count5mnumber默认:24相应5m展示个数相应5m展示个数
count1hnumber默认:24相应1h展示个数相应1h展示个数
count1dnumber默认:30相应1d展示个数相应1d展示个数

200返回说明

{
  "data": {
    "api:_skyapi_getAll": {
      "5m": {
        "count": {
          "step": 300000,
          "unitType": "m",
          "data": [
            [
              1561964400000,
              0
            ]
          ]
        },
        "max": {
          "step": 300000,
          "unitType": "m",
          "data": [
            [
              1561964400000,
              0
            ]
          ]
        },
        "min": {
          "step": 300000,
          "unitType": "m",
          "data": [
            [
              1561964400000,
              0
            ]
          ]
        },
        "avg": {
          "step": 300000,
          "unitType": "m",
          "data": [
            [
              1561964400000,
              0
            ]
          ]
        }
      },
      "1h": {
        "count": {
          "step": 3600000,
          "unitType": "h",
          "data": [
            [
              1561964400000,
              0
            ]
          ]
        },
        "max": {
          "step": 3600000,
          "unitType": "h",
          "data": [
            [
              1561964400000,
              0
            ]
          ]
        },
        "min": {
          "step": 3600000,
          "unitType": "h",
          "data": [
            [
              1561964400000,
              0
            ]
          ]
        },
        "avg": {
          "step": 3600000,
          "unitType": "h",
          "data": [
            [
              1561964400000,
              0
            ]
          ]
        }
      },
      "1d": {
        "count": {
          "step": 86400000,
          "unitType": "d",
          "data": [
            [
              1561910400000,
              8
            ]
          ]
        },
        "max": {
          "step": 86400000,
          "unitType": "d",
          "data": [
            [
              1561910400000,
              20
            ]
          ]
        },
        "min": {
          "step": 86400000,
          "unitType": "d",
          "data": [
            [
              1561910400000,
              4
            ]
          ]
        },
        "avg": {
          "step": 86400000,
          "unitType": "d",
          "data": [
            [
              1561910400000,
              7
            ]
          ]
        }
      }
    }
  },
  "code": 200,
  "msg": "成功",
  "t": 1561964527619
}
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago