You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo"curl -u 'username:password' -X GET 'https://jfrog-instance/api/storageinfo' > jfrog_report.json"| crontab -
5.2 Alert If a User Exceeds 10TB in a Day
SELECT username, sum(size_bytes) / 1e12 AS egress_TB
FROM artifactory_logs
WHERE method ='GET'AND status_code =200AND toDate(timestamp) = today()
GROUP BY username
HAVING egress_TB >10;
6. ClickHouse Queries for Artifactory Egress Reports
6.1 Ensure Artifactory Logs are Ingested into ClickHouse
cat request.log | clickhouse-client --query="INSERT INTO artifactory_logs FORMAT TSV"
7. Query Artifactory Egress Usage
7.1 Total Egress Data Over Time
SELECT toDate(timestamp) ASdate, sum(size_bytes) / 1e12 AS egress_TB
FROM artifactory_logs
WHERE method ='GET'AND status_code =200GROUP BYdateORDER BYdateDESC;
7.2 Egress Breakdown by User
SELECT username, sum(size_bytes) / 1e12 AS egress_TB
FROM artifactory_logs
WHERE method ='GET'AND status_code =200GROUP BY username
ORDER BY egress_TB DESCLIMIT10;
7.3 Egress Breakdown by Repository
SELECT splitByChar('/', url_path)[2] AS repo_name, sum(size_bytes) / 1e12 AS egress_TB
FROM artifactory_logs
WHERE method ='GET'AND status_code =200GROUP BY repo_name
ORDER BY egress_TB DESCLIMIT10;
8. Automate Egress Reporting
8.1 Create a Materialized View for Faster Queries
CREATE MATERIALIZED VIEW egress_summary_mv ENGINE = SummingMergeTree()
ORDER BY (timestamp, username)
ASSELECT
toDate(timestamp) ASdate,
username,
ip_address,
sum(size_bytes) AS total_bytes
FROM artifactory_logs
WHERE method ='GET'AND status_code =200GROUP BYdate, username, ip_address;
8.2 Schedule Reports Using a Cron Job
echo"SELECT date, username, sum(total_bytes) / 1e12 AS egress_TB FROM egress_summary_mv GROUP BY date, username ORDER BY date DESC"| clickhouse-client > daily_egress_report.csv
9. Set Up Alerts for High Egress Usage
9.1 Alert If a Repository Causes a Spike
WITH last_7_days AS (
SELECT toDate(timestamp) ASdate, repo_name, sum(size_bytes) / 1e12 AS egress_TB
FROM artifactory_logs
WHERE method ='GET'AND status_code =200GROUP BYdate, repo_name
)
SELECT repo_name, avg(egress_TB) AS avg_egress, max(egress_TB) AS max_egress
FROM last_7_days
GROUP BY repo_name
HAVING max_egress >2* avg_egress;