npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ali-loghub-sdk

v1.3.1

Published

A sdk for aliyun loghub service.

Downloads

32

Readme

ali-loghub-sdk

npm package

因日常工作原因,目前只支持部分功能,剩余功能之后会逐渐开放,有什么特殊需求的欢迎在Issues中提出!

aliyun 日志服务sdk库

开始使用

  • 安装
$ npm install ali-loghub-sdk --save

若出现无法下载等网络问题,请使用淘宝镜像下载

$ cnpm install ali-loghub-sdk --save
  • 初始化
const Loghub = require('ali-loghub-sdk');

const loghub = new Loghub({
  accessKeyId: "accessKeyId",
  secretAccessKey: "secretAccessKey",
  endpoint: "cn-hangzhou.log.aliyuncs.com",
  projectName: "projectName"
});
  • 获取 logstore
loghub.getLogStores((err, info) => {
   if(err) {
     console.log(err);
   } else {
     console.log(info);
   }
 });
  • 消费日志
/**
 * logStoreName: logstore 名称
 * shard: 从listShards接口获取的值,指定shard
 * count: 返回的 loggroup 数目,范围为 0~1000
 * cursor: 游标,用以表示从什么位置开始读取数据,相当于起点
 */
loghub.pullLogs({
  logStoreName: 'logStoreName',
  shard: '107',
  count: '100',
  cursor: 'cursor'
}, (err, info) => {
  if(err) {
    console.log('err: ', err);
  } else {
    console.log('info: ', info);
  }
});
  • 获取游标 cursor
/**
 * logStoreName: logstore 名称
 * shard: 从listShards接口获取的值,指定shard
 * from: 时间戳,秒,查询的时间点
 */
loghub.getCursor({
  logStoreName: 'logstorename',
  shard: '114',
  from: '1513952882'
}, (err, info) => {
  if(err) {
    console.log('err: ', err);
  } else {
    console.log('info: ', info);
  }
});
  • 获取logstore下所有可用的shard
/**
 * logstorename: logstore 名称
 */
loghub.listShards(logstorename, (err, info) => {
  if(err) {
    console.log('err: ', err);
  } else {
    console.log('info: ', info);
  }
});
  • 按需查找日志
loghub.getLogs({
  logstorename: 'logstorename',
  from: 1513751400,
  to: 1513751500
}, (err, info) => {
  if(err) {
    console.log('err: ', err);
  } else {
    console.log('info: ', info);
  }
});

查询参数列表

| 名称 | 类型 | 是否必选 | 描述 | | ------------ | ------ | ---- | ---------------------------------------- | | logstorename | string | 是 | 查询的logstore名称 | | topic | string | 否 | 查询日志主题 | | from | int | 是 | 查询开始时间点(精度为秒,从 1970-1-1 00:00:00 UTC 计算起的秒数) | | to | int | 是 | 查询结束时间点(精度为秒,从 1970-1-1 00:00:00 UTC 计算起的秒数) | | query | string | 否 | 查询表达式查询表达式 | | line | int | 否 | 请求返回的最大日志条数。取值范围为 0~100,默认值为 100 | | offset | int | 否 | 请求返回日志的起始点。取值范围为 0 或正整数,默认值为 0 | | reverse | bool | 否 | 是否按日志时间戳逆序返回日志。true 表示逆序,false 表示顺序,默认值为 false |