Writes data as a JSON object, and includes field values optionally. The
specified fields will be formatted as JSON and assigned to the field
specified in as
, defaults to
_json.
Function Traits: FieldComputationFunction
, Transformation
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
as | string | optional | _json | Name of output field. |
field [a] | Array of strings | optional | @rawstring | Values and fields that should be converted to JSON. Accepts either a value or array of values. |
The parameter name for field
can be omitted; the following forms are equivalent:
logscale
writeJson("@rawstring")
and:
logscale
writeJson(field="@rawstring")
writeJson()
Examples
Multiple fields can be included. Given events where:
json
a.b.c=5,
a.b.e[0]=6,
a.d=7,
a.f.g=8
use the query function to call:
logscale
writeJson(["a.b.c", "a.b.e[0]", "a.d", "a.f.g"])
It will write the following JSON to each event, respectively:
json
{"a":{"b":{"c":5}}},
{"a":{"b":{"e":[6]}}},
{"a":{"d":7}},
{"a":{"f":{"g":8}}}