```processors: logstransform/internal: opera...
# support
s
Copy code
processors:
  logstransform/internal:
    operators:
      - type: json_parser
        parse_from: body
        output: [add_trace_id,add_traceId]
      - id: add_trace_id
      - type: trace_parser
        if: '"trace_id" in attributes or "span_id" in attributes'
        trace_id:
          parse_from: attributes.trace_id
        span_id:
          parse_from: attributes.span_id
        output: remove_trace_id
      - id: add_traceId
      - type: trace_parser
        if: '"traceId" in attributes or "spanId" in attributes'
        trace_id:
          parse_from: attributes.traceId
        span_id:
          parse_from: attributes.spanId
        output: remove_traceId
      - id: remove_traceId
        type: remove
        if: '"traceId" in attributes'
        field: attributes.traceId
        output: remove_spanId
      - id: remove_spanId
        type: remove
        if: '"spanId" in attributes'
        field: attributes.spanId
      - id: remove_trace_id
        type: remove
        if: '"trace_id" in attributes'
        field: attributes.trace_id
        output: remove_span_id
      - id: remove_span_id
        type: remove
        if: '"span_id" in attributes'
        field: attributes.span_id
n
Please create a different processor pipeline
s
Copy code
logstransform/custom:
    operators:
      - type: copy
        if: '"requestId" in attributes'
        from: attributes.requestId
        to: trace_id
I m getting when using diffrent processor, I this syntax correct ??
@Ankit Nayan
n
Hi you cannot copy something to trace_id, you will have to parse it using trace_parser https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/trace_parser.md If you can share what you want to do, I can help you out.
s
Actually, I am passing trace_id,span_id in attributes and want to copy them to trace_id and span_id field in logs
I have tried logstransform/internal: processor also .It delete the trace_id and span_id from attributes but not create trace_id and span_id as top level field to store in logs level
n
Can you share the json body of a log from the UI, by clicking on details
s
Copy code
{
  "timestamp": 1692873975528000000,
  "id": "2UQZ85QnVma9FwlT45ZhW495zH4",
  "trace_id": "",
  "span_id": "",
  "trace_flags": 0,
  "severity_text": "INFO",
  "severity_number": 9,
  "body": "requestId=46358991-195b-49d8-a2c5-417b20ab87b8 functionName=getHello thisnameSpace=ApiResponse: msg=validation successful",
  "resources_string": {
    "service_name": "unknown_service:node",
    "telemetry_sdk_language": "nodejs",
    "telemetry_sdk_name": "opentelemetry",
    "telemetry_sdk_version": "1.15.2"
  },
  "attributes_string": {
    "functionName": "getHello",
    "requestId": "46358991-195b-49d8-a2c5-417b20ab87b8",
    "thisnameSpace": "ApiResponse"
  },
  "attributes_int": {},
  "attributes_float": {}
}
n
Ahh in this case you will have to parse the body
s
I want to use requestId as trace_id and functionName as span_id and namespace as trace_flag
n
ahh that won’t be possible.
as those top level keys only accept openetelemtry trace_id and spanId
s
okay
n
Can I ask why do you want to map them to trace_id and spanId ? they are already present as attributes.
s
then searching will be faster on reqId,FunctionName
n
to make them faster you will have to convert them to selected field, this you can do it in the old explorer page. https://signoz.io/docs/userguide/logs_fields/#selected-log-fields
s
ohhh , got it
how does it exactly improve searching .when i move field from interesting to selected field??
n
It creates an individual column internally for that attribute. You can read more about clickhouse materialized columns here https://posthog.com/blog/clickhouse-materialized-columns