doc/solutions/components/securitykpi.md
{{< details >}}
{{< /details >}}
The document describes the installation, configuration and user guide of the GitLab Security Metrics and KPIs Solution Component. This security solution component provides metrics and KPIs that can be viewed by business units, time range, vulnerability severity and security types. It can provide a snapshot of the security posture on a monthly or quarterly basis with PDF documents. The data is visualized using a dashboard in Splunk.
This solution exports vulnerability data from GitLab projects or groups using the GraphQL API, sends it to Splunk through the HTTP Event Collector (HEC), and includes an out-of-the-box dashboard for security metrics visualization. The export process is designed to run as a GitLab CI/CD pipeline on a scheduled basis.
export_vulns.pysend_to_splunk.pyrequirements.txt.gitlab-ci.ymlThe solution consists of two main components:
The pipeline runs in two stages:
extract: Fetches vulnerabilities and saves to CSVingest: Sends the vulnerability data to Splunk| Variable | Description | Example Value |
|---|---|---|
SCOPE | Target scope for vulnerability scanning | group:security/appsec or security/my-project |
GRAPHQL_API_TOKEN | GitLab personal access token with API access | glpat-XXXXXXXXXXXXXXXX |
GRAPHQL_API_URL | GitLab GraphQL API URL | https://gitlab.com/api/graphql |
SPLUNK_HEC_TOKEN | Splunk HTTP Event Collector token | 11111111-2222-3333-4444-555555555555 |
SPLUNK_HEC_URL | Splunk HEC endpoint URL | https://splunk.company.com:8088/services/collector |
| Variable | Description | Example Value | Default |
|---|---|---|---|
SEVERITY_FILTER | Comma-separated list of severity levels | CRITICAL,HIGH,MEDIUM | All severities |
VULN_TIME_WINDOW | Time window for vulnerability collection | 24h, 7d, or all | 24h |
The SCOPE variable determines which projects or groups to scan:
mygroup/myprojectgroup:mygroup/subgroupinstanceValid severity levels:
CRITICALHIGHMEDIUMLOWUNKNOWNExample combinations:
CRITICAL,HIGHCRITICAL,HIGH,MEDIUMThe VULN_TIME_WINDOW variable controls how far back to look for vulnerabilities:
<number><unit> where:
number: Any positive integerunit: h for hours or d for days24h: Last 24 hours7h: Last 7 hours15d: Last 15 days30d: Last 30 daysall: All vulnerabilities (useful for first run)Default value: 24h
Example pipeline configurations:
# For 12-hour window
variables:
VULN_TIME_WINDOW: "12h"
# For 3-day window
variables:
VULN_TIME_WINDOW: "3d"
# For all vulnerabilities
variables:
VULN_TIME_WINDOW: "all"
Schedule your pipeline based on your chosen window. For example:
First Run:
VULN_TIME_WINDOW: "all" to collect all historical vulnerabilitiesOngoing Collection:
VULN_TIME_WINDOW to your desired window (24h or 7d)24h: Schedule daily7d: Schedule weeklyThe script sends vulnerabilities as events to Splunk.
gitlab_vulns in Splunkgitlab_vulns (this index is referenced in the base search of the provided Splunk dashboard)Each event includes:
The provided dashboard offers comprehensive visibility into your GitLab vulnerability data with the following visualizations:
To set up the dashboard:
Business Unit Mapping:
Create a CSV file with two columns:
project_url,business_unit
Map each GitLab project URL to its corresponding business unit.
Upload the file to Splunk as a lookup table:
business_unit_mapping.csv.<splunk_dir>/etc/apps/search/lookups/business_unit_mapping.csv.Dashboard Installation:
vuln_metrics_dashboard.xml file.vuln_metrics_dashboard.xml.The intermediate CSV file contains:
detectedAt: Detection timestamptitle: Vulnerability titleseverity: Severity levelprimaryIdentifier: Vulnerability identifierexporter: Scanner nameprojectPath: GitLab project pathprojectUrl: Project URLdescription: Vulnerability descriptionwebUrl: Vulnerability details URLThe solution includes:
Token Permissions:
Schedule Frequency:
VULN_TIME_WINDOWMonitoring:
Common issues and solutions:
No vulnerabilities exported:
Splunk ingestion fails: