API Events

API Events (API Calls) are one of the entities tracked by Moesif. The Moesif Middleware SDKs are designed to capture the API calls and attributes automatically through framework specific middleware so you don’t need to manually log them.

Moesif tracks a predefined list of properties for each HTTP request and the associated response such as HTTP status code and latency of the call.
For the full list of tracked properties, view the Event Log API Reference

HTTP body

Moesif will capture the full request and response bodies. For flexibility, you can scrub any data before being sent to Moesif in the SDKs.

Moesif supports a variety of text and binary encodings such as XML, JSON, or ProtoBuf. However, only JSON data is analyzed at this time.

Custom metadata

In addition to the predefined properties, you can add custom metadata to any API call. For example, you may want to append a VM instance id, a trace_id, or a secondary tenant_id with the API call.

{
  "some_string": "I am a string",
  "some_int": 77,
  "some_object": {
      "some_sub_field": "some_value"
    }
}

You can filter and segment using custom metadata fields. For example, if you add the user’s company field, you can filter on 500 errors and group by company to see which company is experiencing the most problems.

Segment on Custom Fields

1. Maintain consistent datatypes

Once a JSON key is seen by Moesif with a specific JSON datatype, you cannot send a different JSON datatype using the same key. For example, if you previously sent to Moesif the following custom metadata for an API call:

{
  "some_string": "I am a string",
  "some_int": 77,
  "some_object": {
      "some_sub_field": "some_value"
    }
}

Then, Moesif automatically saves some_string as a JSON string in the metadata schema. You cannot later send a JSON Number using the same some_string key. This is true regardless of the number of levels relative to the object root. The below metadata would now be invalid:

{
  "some_int": 77,
  "some_object": {
      "some_string": 23,
      "some_sub_field": "some_value"
    }
}

The metadata schema is shared across your organization and applications.

2. Avoid dots characters

Be aware that Dot characters in a JSON key for custom metadata will be converted into an underscore by Moesif automatically. Hoever, Dot characters in a JSON value are fine and will not be transformed.

For example,

{
  "so.me_str.ing": "I am a string",
  "some.int": 77.23
}

Will be converted by Moesif to:

{
  "so_me_str_ing": "I am a string",
  "some_int": 77.23
}

Updated:

Leave a Comment