Skip to content

pkg/log: extend log configuration#664

Merged
jkralik merged 37 commits into
mainfrom
jkralik/fix/log
Feb 23, 2022
Merged

pkg/log: extend log configuration#664
jkralik merged 37 commits into
mainfrom
jkralik/fix/log

Conversation

@jkralik
Copy link
Copy Markdown
Member

@jkralik jkralik commented Feb 8, 2022

Examples:
COAP:

{
    "L": "DEBUG",
    "T": "2022-02-22T15:26:42.524269462Z",
    "M": "finished unary call from the device with code Changed",
    "startTime": "2022-02-22T15:26:42.481380231Z",
    "durationMs": 40.756,
    "request": {
        "body": {
            "accesstoken": "0ca0c61204a543abd3ee0ea2d16e829c",
            "authprovider": "plgd",
            "di": "b5a2a42e-b285-42f1-a36b-034c8fc8efd5"
        },
        "href": "/oic/sec/account",
        "method": "POST"
    },
    "response": {
        "body": {
            "accesstoken": "eyJhbGciOiJFUzI1NiIsImtpZCI6ImIwZWE1MGMxLTY3MGMtNWIwOC1iNjc3LWQzZTdlZmFlNWUwZiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiaHR0cHM6Ly9sb2NhbGhvc3Q6MjAwMDkvIl0KLCJjbGllbnRfaWQiOiJ0ZXN0IiwiaHR0cHM6Ly9wbGdkLmRldi9kZXZpY2VJZCI6ImI1YTJhNDJlLWIyODUtNDJmMS1hMzZiLTAzNGM4ZmM4ZWZkNSIsImlhdCI6MTY0NTU0MzYwMgosImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0OjIwMDA5LyIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgZW1haWwgb2ZmbGluZV9hY2Nlc3MgcjoqIHc6KiIsInN1YiI6IjEifQ.y-eMN0RL7w4xxeVLHrc_8dugXfYOVMrKghky6EcueLTpgLMib8Src-e_Q_3d-QjSO6qRe2KrPmSdzjoRjy5ZYg",
            "expiresin": -1,
            "redirecturi": "",
            "refreshtoken": "refresh-token",
            "uid": "1"
        },
        "code": "Changed"
    },
    "protocol": "COAP"
}

GRPC:

{
    "L": "WARN",
    "T": "2022-02-21T20:29:11.522144612Z",
    "M": "finished unary call with code PermissionDenied",
    "response": {
        "code": "PermissionDenied",
        "error": "rpc error: code = PermissionDenied desc = cannot validate user access: rpc error: code = PermissionDenied desc = access denied"
    },
    "durationMs": 1.846,
    "protocol": "GRPC",
    "startTime": "2022-02-21T20:29:11.519007649Z",
    "request": {
        "correlationId": "8d08dd47-9b6e-4eb4-bbb9-3f1bcfa3f025",
        "deviceId": "a",
        "href": "/b",
        "jwt": {
            "sub": "1"
        },
        "method": "CreateResource",
        "service": "resourceaggregate.pb.ResourceAggregate"
    }
}

HTTP:

{
    "L": "DEBUG",
    "T": "2022-02-21T21:19:26.986032016Z",
    "M": "finished unary call with status code 200",
    "durationMs": 75.45,
    "request": {
        "href": "/api/v1/devices/6f1e8e14-e4fe-4282-672b-d6f89bd4a9f6/resource-links/switches",
        "jwt": {
            "sub": "1"
        },
        "method": "POST"
    },
    "response": {
        "code": 200
    },
    "startTime": "2022-02-21T21:19:26.909713334Z",
    "protocol": "HTTP"
}

Loki parser: https://grafana.com/docs/loki/latest/logql/log_queries/#json

https://github.com/plgd-dev/www/pull/48

@jkralik jkralik linked an issue Feb 8, 2022 that may be closed by this pull request
Comment thread coap-gateway/service/message/response.go
@jkralik jkralik marked this pull request as ready for review February 16, 2022 14:50
Comment thread coap-gateway/service/signIn.go Outdated
@jkralik jkralik requested a review from ondrejtomcik February 17, 2022 14:24
Comment thread pkg/net/grpc/server/makeDefaultOptions.go Outdated
@ondrejtomcik
Copy link
Copy Markdown
Member

ondrejtomcik commented Feb 19, 2022

Could you please explain value "coap.service":"coap-gateway"in "request from client" log message? I didn't get it. Same for "http.service": "http-gateway". Name it just service.

Update @jkralik : Just came to my mind that service is not needed at all. This is appended by the log aggregator, it is a duplicit information. It can me completely removed.

@ondrejtomcik
Copy link
Copy Markdown
Member

ondrejtomcik commented Feb 19, 2022

Why you are using protocol specific keys like "coap.start_time"? It should be request.start_time, request, response, and so on.

TODO: camel case + part of the request/response log object.

@ondrejtomcik
Copy link
Copy Markdown
Member

Why plgd.deviceID? What other deviceID will be there? use only deviceID key please.

@ondrejtomcik
Copy link
Copy Markdown
Member

ondrejtomcik commented Feb 19, 2022

Both CoAP as well as HTTP have href. Use just href key. If I would want to filter HTTP gateway, I would combine href and service keys.

@ondrejtomcik
Copy link
Copy Markdown
Member

Can you unify this?
"finished unary call with code Internal"
"finished unary call with status code 403"

Comment thread charts/plgd-hub/README.md
Comment thread coap-gateway/service/log.go Outdated
Comment thread coap-gateway/service/log.go Outdated
Comment thread certificate-authority/config.yaml
Comment thread certificate-authority/config.yaml
Comment thread coap-gateway/config.yaml
@sonarqubecloud
Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

73.0% 73.0% Coverage
4.2% 4.2% Duplication

@jkralik jkralik merged commit d45adaa into main Feb 23, 2022
@jkralik jkralik deleted the jkralik/fix/log branch February 23, 2022 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize PLGD application logs of Kubernetes deployment.

3 participants