Gitlab clone pull push log information

Time:2021-7-1

Background:

The company pays attention to information security, uses gitlab for code management, and requires all users’ remote operations (push, synchronization) to be recorded.

By viewing gitlab official documents, the information is as follows:

Various log storage locations in the background of gitlab/var/log/gitlab/

production.log

Note: this log only records the operation through HTTP

Storage directory:/var/log/gitlab/gitlab-rails/

production_json.logInside is the JSON request string.

{
    "method": "GET",
    "path": "/test_user/test_project.git/info/refs",
    "format": "*/*",
    "controller": "Projects::GitHttpController",
    "action": "info_refs",
    "status": 200,
    "duration": 268.22,
    "view": 0.48,
    "db": 14.41,
    "time": "2019-06-27T10:59:56.324Z",
    "params": [
        {
            "key": "service",
            "value": "git-receive-pack"
        },
        {
            "key": "namespace_id",
            "value": "test_user"
        },
        {
            "key": "project_id",
            "value": "test_project.git"
        }
    ],
    "remote_ip": "192.168.XX.XX",
    "user_id": 3,
    "username": "test_user",
    "ua": "git/2.21.0.windows.1",
    "queue_duration": null,
    "correlation_id": "b02c02f9-0167-49bf-965f-e4cc86d6751f"
}

Valuable information in the log:

  • Synchronous action:service:git-receive-pack
  • Push operation:service:git-upload-pack
  • Project Name:project_id:test_project.git
  • IP address:remote_ip:192.168.XX.XX
  • user name:username:test_user
  • Time:time:2019-06-27T10:59:56.324Z(UTC format plus 8 hours equals Beijing time)
  • Status:status:200(200 indicates success, others indicate failure)
  • Action information:action:info_refs(for each synchronization and push operation, you need to use this field to filter whether the log is an update or push operation.)

For data operations with JSON nesting, it is recommended to read this article to improve work efficiency.
How to get nested JSON data content gracefully by go

gitlab-shell.log

**Note: this log only records the operation of gitclone protocol

Log directory:/var/log/gitlab/gitlab-shell
The following log is not in JSON format, and you need to operate on the string yourself.

time="2019-07-02T11:17:48+08:00" level=info msg="executing git command" command="gitaly-receive-pack unix:/var/opt/gitlab/gitaly/gitaly.socket {\"repository\":{\"storage_name\":\"default\",\"relative_path\":\"test_user/test_project.git\",\"git_object_directory\":\"\",\"git_alternate_object_directories\":[],\"gl_repository\":\"project-5\",\"gl_project_path\":\"test_user/test_project\"},\"gl_repository\":\"project-5\",\"gl_project_path\":\"test_user/test_project\",\"gl_id\":\"key-3\",\"gl_username\":\"test_user\",\"git_config_options\":[],\"git_protocol\":null}" pid=23657 user="user with id key-3"

Valuable information in the log:

  • Synchronous action:command:gitaly-receive-pack
  • Push operation:command:gitaly-upload-pack
  • Project Name:gl_project_path:test_user/test_project
  • IP address:remote_ip:192.168.XX.XX
  • user name:gl_username:test_user
  • Time:time:2019-07-02T11:17:48+08:00(UTC format plus 8 hours equals Beijing time)
  • Status:status:200(200 indicates success, others indicate failure)
  • Action information:action:info_refs(for each synchronization and push operation, you need to use this field to filter whether the log is an update or push operation.)

Reference documents:

  1. Gitlab official log interpretation document

This article first appeared inBigyoung station

Recommended Today

Detailed steps for installing Perl and Komodo IDE for windows

Perl official website: https://www.perl.org/Perl document: https://perldoc.perl.org/Download address: https://www.perl.org/get.html The installation package of Perl Windows version is divided into activestate Perl and strawberry Perl. For the difference between the two, see: http://www.zzvips.com/article/202134.htm Note: the download speed of activestate Perl is slow. You may need KX to surf the Internet I have uploaded all the versions of […]