Skip to content

Add a new header attribute for advanced logging information #21

@MephistosFaust

Description

@MephistosFaust

Hi folks,
I have the following problem. The information which will be logged into the remote_client_id field in kibana are either a uuid or an info_user_id.

morgan.token("remote_client_id", function getRemoteClientId(
      request,
      response
    ) {
      let rcId = "";

      try {
        rcId = request.headers.customeruuid;

        if (request.headers[CUSTOMER_UUID]) {
          rcId = request.headers[CUSTOMER_UUID];
        }

        if (request.headers[AUTH_INFO_USER_ID]) {
          rcId = request.headers[AUTH_INFO_USER_ID];
        }

        if (request.headers[AUTH_REMOTE_CLIENT_ID]) {
          rcId = request.headers[AUTH_REMOTE_CLIENT_ID];
        }

        if (!rcId) {
          rcId = "unknown";
        }
      } catch (e) {
        rcId = "error";
      }

      return rcId;
    });

Both of this informations are a little bit miss leading, since both are not the real client Id.
I want to write the real client Id (from an oauth token in my case) into this log field.

Unfortunately I cannot use these header attributes and just fill it with another information because other services reliant on the right UUID and an info_user_id.

So the only way to solve that problem I can imagine is to ad another if-clause and extend the logic in the method above with a new header attribute. Something like this:

if (request.headers[AUTH_REMOTE_CLIENT_ID])
 {
          rcId = request.headers[AUTH_REMOTE_CLIENT_ID];
        }

Is this an option for you?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions