languages / node / usage / custom-events

Node Usage - Custom Events

Custom events allow you to extend beyond events already defined in timber.events. If you aren't sure what an event is, please read the "Metdata, Context, and Events" doc.

How to use it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Using console.log:
console.warn("Payment rejected", {
  event: {
    payment_rejected: { customer_id: "abcd1234", amount: 100, reason: "Card expired" }
  }
});

// Using winston:
winston.warn("Payment rejected", {
  event: {
    payment_rejected: { customer_id: "abcd1234", amount: 100, reason: "Card expired" }
  }
});

// Using bunyan:
logger.warn({
  event: {
    payment_rejected: { customer_id: "abcd1234", amount: 100, reason: "Card expired" }
  }
}, "Payment rejected");
  1. Search it with queries like: type:payment_rejected or payment_rejected.amount:>100
  2. Alert on it with threshold based alerts
  3. Graph & visualize it
  4. View this event's data and context

How it works

When this event is received by the Timber service we'll define a namespaced schema based on the event name. In this case, the namespace would be payment_rejected. The data structure of your log will look like:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "message": "Payment rejected",
  "level": "warn",
  "event": {
    "custom": {
      "payment_rejected": {
        "customer_id": "abcd1234",
        "amount": 100,
        "reason": "Card expired"
      }
    }
  }
}
Questions?

Chat with us, just click the talk button in the bottom right of this page.

Chat with us
Sign Up

Log better and solve problems faster, today. Install in under a minute.

Sign Up