Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add transform to field details #10

Closed
wants to merge 5 commits into from

Conversation

victorhos
Copy link

@victorhos victorhos commented Sep 21, 2023

What is being delivered?

  • Added a change to the details field redirected to the Dynatrace data.details field.

Motivation:

  • This test is necessary to increase the logs that are sent from Auth0 with errors to improve troubleshooting.

Evidences:

Read listening: Link:

  1. Test full log:
  • log ingest:
    {
      "log_id":"requested",
      "data":{
         "_id":"_id6",
         "date":"2023-10-19T14:05:43",
         "description":"test detail full",
         "details":{
            "request":{
               "method":"data_details_request_method",
               "path":"data_details_request_path"
            },
            "response":{
               "body":"data_details_response_body",
               "statusCode":400
            }
         },
         "log_id":"log_id",
         "type":"type_custom"
      }
    }
  • log in Dynatrace:
    image
    image
  1. Test without details key should return N/A
  • log ingest:
    {
       "log_id":"requested",
       "data":{
          "_id":"_id7",
          "date":"2023-10-19T14:15:43",
          "description":"test detail n/a",
          "log_id":"log_id",
          "type":"type_custom"
       }
    }
  • log in Dynatrace:
    image
    image

2 - What is being delivered?
An error occurred when running pre-commit with the Docker command. To solve this, add permissions for the root user in the main folder:

root@29c0c90ea5bc:/app# pre-commit run --all-files
An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory?
Check the log at /root/.cache/pre-commit/pre-commit.log
root@29c0c90ea5bc:/app# cat /root/.cache/pre-commit/pre-commit.log
### version information

'''
pre-commit version: 3.5.0
git --version: git version 2.30.2
sys.version:
    3.9.2 (default, Feb 28 2021, 17:03:44) 
    [GCC 10.2.1 20210110]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux
'''

### error information

'''
An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory?
'''

'''
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pre_commit/git.py", line 58, in get_root
    cmd_output('git', 'rev-parse', '--show-cdup')[1].strip(),
  File "/usr/local/lib/python3.9/dist-packages/pre_commit/util.py", line 116, in cmd_output
    returncode, stdout_b, stderr_b = cmd_output_b(*cmd, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/pre_commit/util.py", line 110, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/usr/bin/git', 'rev-parse', '--show-cdup')
return code: 128
stdout: (none)
stderr:
    fatal: detected dubious ownership in repository at '/app'
    To add an exception for this directory, call:
    
    	git config --global --add safe.directory /app

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/usr/local/lib/python3.9/dist-packages/pre_commit/main.py", line 370, in main
    _adjust_args_and_chdir(args)
  File "/usr/local/lib/python3.9/dist-packages/pre_commit/main.py", line 180, in _adjust_args_and_chdir
    toplevel = git.get_root()
  File "/usr/local/lib/python3.9/dist-packages/pre_commit/git.py", line 64, in get_root
    raise FatalError(
pre_commit.errors.FatalError: git failed. Is it installed, and are you in a Git repository directory?
'''
root@29c0c90ea5bc:/app# pwd

@victorhos victorhos self-assigned this Sep 21, 2023
@victorhos victorhos force-pushed the feature/add-transformer-field branch from 2e65ded to 353469e Compare September 22, 2023 14:56
@willianantunes
Copy link
Contributor

question: The guide says you can use one of the four keys to store content. I don't think it says you can use two or even four of them to store the content. For example, I understand this is a valid example:

[
    {
        "content": "Exception: Did you throw you television on me?",
        "log.source": "cockatiel",
        "timestamp": "2022-11-21T16:15:40.0000",
        "severity": "error",
        "service.name": "cockatiel-sniffer",
        "service.namespace": "dev-stage-salt-mustache-cluster",
        "custom.attribute": "attribute value"
    }
]

This is one invalid because it uses two keys to store content:

[
    {
        "content": "Exception: Did you throw you television on me?",
        "body": "Exception: Did you throw you television on me?",
        "log.source": "cockatiel",
        "timestamp": "2022-11-21T16:15:40.0000",
        "severity": "error",
        "service.name": "cockatiel-sniffer",
        "service.namespace": "dev-stage-salt-mustache-cluster",
        "custom.attribute": "attribute value"
    }
]

Also, the Log Monitoring API has the following rule:

Content. If the content key is not set, the whole JSON is parsed as the content.

Did you test your solution in an actual Dynatrace Environment? How did it behave?

@willianantunes willianantunes requested a review from a team October 2, 2023 18:50
@victorhos victorhos force-pushed the feature/add-transformer-field branch from 5306179 to 417de17 Compare October 17, 2023 01:42
@victorhos victorhos requested review from brunobertolini, willianantunes and a team and removed request for a team, brunobertolini and willianantunes October 19, 2023 14:46
@victorhos victorhos closed this Dec 26, 2023
@victorhos victorhos deleted the feature/add-transformer-field branch December 26, 2023 13:38
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.

2 participants