Skip to content

Collector "GitLab" Configuration Manual

1. Configuration Example

1.1 Modify the following configuration in the script file

Python
1
2
3
4
# GitLab URL
gitlab_url    = "https://gitlab.xxxx.com"
# GitLab personal access token
private_token = "-txxxxk-Fxxxxxz"

1.2 Create a Guance Connector

In the "Manage / Experimental Features" section, enable the "Guance Connector".

Go to "Development / Connectors / Add Connector", select the type as "Guance", and fill in the relevant configuration parameters according to the input box prompts (this script requires the ID value to be "Guance").

For more information on selecting Guance connector nodes, please refer to: Manual / Interface and Operations / Guance Nodes

2. Tutorial for Obtaining a GitLab Personal Access Token:

  1. Log in to GitLab.
  2. In the top right corner, select your avatar.
  3. Select Edit Profile.
  4. On the left sidebar, select Access Tokens.
  5. Enter the name of the token and the expiration date.
  6. The token expires at midnight UTC on this date.
  7. If you do not enter an expiration date, it will automatically be set to 365 days after the current date.
  8. By default, this date can be up to 365 days after the current date.
  9. Set Scopes
  10. Select Create Personal Access Token

Save the personal access token in a secure place. Once you leave the page, you will no longer be able to access the token!

3. Data Reporting Format

After data is synchronized successfully, you can view the data in the "LOG" section of TrueWatch.

Example of reported data:

Commit data

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{
    "measurement": "gitlab_commits",
    "tags":{
        "group_name"     : "xxxxx",
        "project_name"   : "xxxxx",
        "committer_name" : "xxxxx",
        "committer_email": "[email protected]"
    },
    "fields":{
        "commit sha"    : "xxxxx",
        "web_url"       : "xxxxx",
        "message"       : "xxxxx",
        "Added lines"   : "xxxxx",
        "Deleted lines" : "xxxxx",
        "Total lines"   : "xxxxx",
        "committed_date": "xxxxx"
    }
}

Issue data

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
   "measurement": "gitlab_issues",
   "tags"       : {
       "group_name"  : "xxxxx",
       "project_name": "xxxxx",
       "author_name" : "xxxxx"
   },
   "fields"     : {
       "title"               : "xxxxx",
       "description"         : "xxxxx",
       "state"               : "xxxxx",
       "updated_at"          : "xxxxx",
       "closed_at"           : "xxxxx",
       "web_url"             : "xxxxx",
       "type"                : "xxxxx",
       "due_date"            : "xxxxx",
       "issue_type"          : "xxxxx",
       "user_notes_count"    : "xxxxx",
       "merge_requests_count": "xxxxx",
       "upvotes"             : "xxxxx",
       "downvotes"           : "xxxxx"
   }
}

Merge data

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
{
  "measurement": "gitlab_merges",
  "tags"       : {
      "group_name"  : "xxxxx",
      "project_name": "xxxxx",
      "author_name" : "xxxxx"
  },
  "fields": {
      "title"           : "xxxxx",
      "description"     : "xxxxx",
      "state"           : "xxxxx",
      "updated_at"      : "xxxxx",
      "closed_at"       : "xxxxx",
      "merged_at"       : "xxxxx",
      "web_url"         : "xxxxx",
      "merge_commit_sha": "xxxxx",
      "merge_status"    : "xxxxx",
      "upvotes"         : "xxxxx",
      "downvotes"       : "xxxxx"
  }
}

Explanation of some fields:

Field Type Description
group_name String Group Name
project_name String Project Name
author_name String Operator Name

X. Appendix

Please refer to the official GitLab documentation:

Guance Documentation

Please refer to the official Guance documentation: