Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"id": 1,
"options": {
"content": "## Welcome to OSV.dev Observability\n\nChoose the dashboard below that best matches what you are investigating:\n\n| Dashboard | Best For / Questions Answered | Key Signals |\n| :--- | :--- | :--- |\n| **[1. Executive Overview & SLAs](/d/osv-exec-overview)** | **Overall health & SLO status** — *Are the Website & API meeting 99.9% availability (7d) and per-endpoint P50/P90/P95 latency SLOs? Are advisories ingested within our 2-hour pipeline target?* | Website & API 99.9% availability (7d) & P50/P90/P95 latency SLOs (`GET /v1/vulns/{id}`, `POST /v1/query`, `POST /v1/querybatch`), worker success rate, importer-to-available pipeline latency |\n| **[2. Ingestion & Worker Pipeline Operations](/d/osv-pipeline-ingestion-ops)** | **On-call pipeline triage** — *Is Pub/Sub backed up? Are worker pools scaling and draining fast enough? Which tasks recently failed?* | Queue depth (`default` / `reimport` / `cves`), intake vs. drain rate, error log triage links, reconciler & deleter safety limits |\n| **[3. Vulnerability Data Quality & Ecosystem Health](/d/osv-data-quality-drift)** | **Dataset integrity & feed freshness** — *Are Datastore and GCS out of sync? Which upstream feeds are stale or triggering linter errors?* | `recordchecker` drift, `osv-linter` findings by source/rule, feed staleness, `all.zip` export sizes, Gitter commit scan & error rate |\n| **4. CVE & Feed Conversions *(Planned)*** | **`vulnfeeds/` & CNA conversion quality** — *Why are CVEs failing to convert? How are CVEListV5, NVD, Debian, and Alpine converters running?* | Conversion funnel & outcomes, range extraction sources, Assigner CNA scorecards, `vulnfeeds/` CronJob status |\n\n---\n**Planned Deep-Dive Dashboards (Upcoming):** *5. API Serving & Analytics* · *6. Gitter & Recoverer Deep-Dive* · *7. CronJobs & Storage Capacity*\n\n*Tip: Click the **Plutono** icon, **Home**, or **Observability Directory** in the top navigation from any dashboard to return to this directory.*",
"content": "## Welcome to OSV.dev Observability\n\nChoose the dashboard below that best matches what you are investigating:\n\n| Dashboard | Best For / Questions Answered | Key Signals |\n| :--- | :--- | :--- |\n| **[1. Executive Overview & SLAs](/d/osv-exec-overview)** | **Overall health & SLO status** — *Are the Website & API meeting 99.9% availability (7d) and per-endpoint P50/P90/P95 latency SLOs? Are advisories ingested within our 2-hour pipeline target?* | Website & API 99.9% availability (7d) & P50/P90/P95 latency SLOs (`GET /v1/vulns/{id}`, `POST /v1/query`, `POST /v1/querybatch`), worker success rate, importer-to-available pipeline latency |\n| **[2. Ingestion & Worker Pipeline Operations](/d/osv-pipeline-ingestion-ops)** | **On-call pipeline triage** — *Is Pub/Sub backed up? Are worker pools scaling and draining fast enough? Which tasks recently failed?* | Queue depth (`default` / `reimport` / `cves`), intake vs. drain rate, error log triage links, reconciler & deleter safety limits |\n| **[3. Vulnerability Data Quality & Ecosystem Health](/d/osv-data-quality-drift)** | **Dataset integrity & feed freshness** — *Are Datastore and GCS out of sync? Which upstream feeds are stale or triggering linter errors?* | `recordchecker` drift, `osv-linter` findings by source/rule, feed staleness, `all.zip` export sizes, Gitter commit scan & error rate |\n| **4. CVE & Feed Conversions *(Planned)*** | **`vulnfeeds/` & CNA conversion quality** — *Why are CVEs failing to convert? How are CVEListV5, NVD, Debian, and Alpine converters running?* | Conversion funnel & outcomes, range extraction sources, Assigner CNA scorecards, `vulnfeeds/` CronJob status |\n| **[6. Gitter & Recoverer Deep-Dive](/d/osv-gitter-recoverer)** | **Git cache & task recovery health** — *How full is Gitter's 6TiB SSD cache? Which Git endpoints are slow or hitting data errors?* | SSD disk fullness, Gitter endpoint QPS & P50–P99 latency, commit scan velocity, `bad_hash`/`bad_repo_url`, recoverer repairs |\n\n---\n**Planned Deep-Dive Dashboards (Upcoming):** *5. API Serving & Analytics* · *7. CronJobs & Storage Capacity*\n\n*Tip: Click the **Plutono** icon, **Home**, or **Observability Directory** in the top navigation from any dashboard to return to this directory.*",
"mode": "markdown"
},
"pluginVersion": "7.5.52",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ configMapGenerator:
- executive-overview.json=dashboards/executive-overview.json
- pipeline-ingestion-ops.json=dashboards/pipeline-ingestion-ops.json
- data-quality-drift.json=dashboards/data-quality-drift.json
- gitter-recoverer-deep-dive.json=dashboards/gitter-recoverer-deep-dive.json
12 changes: 12 additions & 0 deletions go/cmd/gitter/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"syscall"
"time"

"github.com/google/osv.dev/go/internal/metrics"
"github.com/google/osv.dev/go/internal/osvutil"
"github.com/google/osv.dev/go/logger"
)
Expand Down Expand Up @@ -151,6 +152,10 @@ func refreshRepo(ctx context.Context, repoURL string, forceUpdate bool) error {
// Clone
logger.DebugContext(ctx, "Cloning git repository")
if err := cloneRepo(ctx, repoURL, repoPath); err != nil {
if !osvutil.IsContextError(err) {
metrics.RecordGitterDataError(metrics.GitterErrorFetch)
}

return fmt.Errorf("git clone failed: %w", err)
}
} else {
Expand Down Expand Up @@ -192,6 +197,9 @@ func refreshRepo(ctx context.Context, repoURL string, forceUpdate bool) error {
}

if reason != "" {
if !osvutil.IsContextError(err) {
metrics.RecordGitterDataError(metrics.GitterErrorFetch)
}
if ok {
logger.WarnContext(ctx, "Fetch failed due to "+reason+". Using local repo.",
slog.Duration("sinceLastFetch", time.Since(lastFetchTime)),
Expand All @@ -212,6 +220,10 @@ func refreshRepo(ctx context.Context, repoURL string, forceUpdate bool) error {

logger.DebugContext(ctx, "Cloning git repository after fallback")
if err := cloneRepo(ctx, repoURL, repoPath); err != nil {
if !osvutil.IsContextError(err) {
metrics.RecordGitterDataError(metrics.GitterErrorFetch)
}

return fmt.Errorf("git clone failed after fallback: %w", err)
}
}
Expand Down
26 changes: 18 additions & 8 deletions go/cmd/gitter/gitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,25 @@ func logRequestCompletion(ctx context.Context, endpoint string, start time.Time,

func updateDiskMetrics(dir string) {
var stat syscall.Statfs_t
if err := syscall.Statfs(dir, &stat); err != nil {
return
if err := syscall.Statfs(dir, &stat); err == nil && stat.Bsize > 0 && stat.Blocks != 0 {
blockSize := float64(stat.Bsize)
usedBytes := float64(stat.Blocks-stat.Bfree) * blockSize
totalBytes := float64(stat.Blocks) * blockSize
metrics.GitterDiskUsedBytes.Set(usedBytes)
metrics.GitterDiskTotalBytes.Set(totalBytes)
}
if stat.Bsize <= 0 || stat.Blocks == 0 {

entries, err := os.ReadDir(filepath.Join(dir, gitStoreFileName))
if err != nil {
return
}
blockSize := float64(stat.Bsize)
usedBytes := float64(stat.Blocks-stat.Bfree) * blockSize
totalBytes := float64(stat.Blocks) * blockSize
metrics.GitterDiskUsedBytes.Set(usedBytes)
metrics.GitterDiskTotalBytes.Set(totalBytes)
var repos int
for _, entry := range entries {
if entry.IsDir() {
repos++
}
}
metrics.GitterReposCached.Set(float64(repos))
}

func getRepoDirName(repoURL string) string {
Expand Down Expand Up @@ -714,6 +722,7 @@ func affectedCommitsHandler(w http.ResponseWriter, req *http.Request) {
affectedCommits = repo.AffectedSingleBranch(ctx, se)
}
metrics.RecordGitterCommitsScanned(len(affectedCommits))
metrics.RecordGitterCommitRangeSize("/affected-commits", len(affectedCommits))

cherryPickedEvents := make([]*pb.Event, 0, len(cherrypicks.Introduced)+len(cherrypicks.Fixed)+len(cherrypicks.Limit))
for _, h := range cherrypicks.Introduced {
Expand Down Expand Up @@ -1094,6 +1103,7 @@ func commitDiffsHandler(w http.ResponseWriter, req *http.Request) {
return
}
metrics.RecordGitterCommitsScanned(len(commits))
metrics.RecordGitterCommitRangeSize("/commit-diffs", len(commits))

pbCommits := make([]*pb.CommitDiff, 0, len(commits))
for _, c := range commits {
Expand Down
63 changes: 63 additions & 0 deletions go/cmd/gitter/gitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import (
"encoding/hex"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"time"

"github.com/google/go-cmp/cmp"
pb "github.com/google/osv.dev/go/internal/gitter/pb/repository"
"github.com/google/osv.dev/go/internal/metrics"
"github.com/prometheus/client_golang/prometheus/promhttp"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
Expand Down Expand Up @@ -986,3 +992,60 @@ func TestCommitDiffsHandler(t *testing.T) {
})
}
}

func scrapeGitterMetrics(t *testing.T) string {
t.Helper()
req := httptest.NewRequest(http.MethodGet, "/metrics", nil)
rec := httptest.NewRecorder()
promhttp.Handler().ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("expected 200 from /metrics, got %d", rec.Code)
}

return rec.Body.String()
}

func metricSampleValue(t *testing.T, body, metricPrefix string) float64 {
t.Helper()
for line := range strings.SplitSeq(body, "\n") {
if valStr, ok := strings.CutPrefix(line, metricPrefix+" "); ok {
val, err := strconv.ParseFloat(strings.TrimSpace(valStr), 64)
if err != nil {
t.Fatalf("failed to parse value for %q from line %q: %v", metricPrefix, line, err)
}

return val
}
}

return 0
}

func TestUpdateDiskMetrics(t *testing.T) {
tmpDir := t.TempDir()
storeDir := filepath.Join(tmpDir, gitStoreFileName)
for _, repo := range []string{"repo-a", "repo-b"} {
if err := os.MkdirAll(filepath.Join(storeDir, repo), 0o755); err != nil {
t.Fatalf("failed to create repo dir: %v", err)
}
}
// Regular files in the git-store directory should not be counted as cached repos.
if err := os.WriteFile(filepath.Join(storeDir, "not-a-repo.tmp"), []byte("x"), 0o600); err != nil {
t.Fatalf("failed to write temp file: %v", err)
}

beforeBody := scrapeGitterMetrics(t)
beforeBucket := metricSampleValue(t, beforeBody, `osv_gitter_commit_range_size_commits_bucket{operation="/commit-diffs",le="10"}`)

updateDiskMetrics(tmpDir)
metrics.RecordGitterCommitRangeSize("/commit-diffs", 7)

afterBody := scrapeGitterMetrics(t)
if !strings.Contains(afterBody, "osv_gitter_repos_cached 2") {
t.Errorf("expected metrics output to contain %q, got:\n%s", "osv_gitter_repos_cached 2", afterBody)
}
afterBucket := metricSampleValue(t, afterBody, `osv_gitter_commit_range_size_commits_bucket{operation="/commit-diffs",le="10"}`)
if afterBucket != beforeBucket+1 {
t.Errorf("expected /commit-diffs le=10 bucket to increment from %v to %v, got %v", beforeBucket, beforeBucket+1, afterBucket)
}
}
29 changes: 29 additions & 0 deletions go/internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ var (
Help: "Total capacity in bytes of Gitter's persistent SSD cache disk.",
},
)

// GitterReposCached tracks the number of Git repositories cached on Gitter's persistent SSD disk.
GitterReposCached = promauto.NewGauge(
prometheus.GaugeOpts{
Name: "osv_gitter_repos_cached",
Help: "Number of Git repositories cached on Gitter's persistent SSD disk.",
},
)

// GitterCommitRangeSizeCommits tracks the distribution of commit counts returned per range request.
GitterCommitRangeSizeCommits = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "osv_gitter_commit_range_size_commits",
Help: "Distribution of the number of commits evaluated or returned per Gitter range request.",
Buckets: []float64{0, 1, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 50000},
},
[]string{"operation"},
)
)

// TaskStatus represents the outcome of processing a worker task.
Expand Down Expand Up @@ -346,3 +364,14 @@ func RecordGitterDataError(errType GitterErrorType) {
func RecordGitterOperation(operation string, status string, duration time.Duration) {
GitterOperationDurationSeconds.WithLabelValues(operation, status).Observe(duration.Seconds())
}

// RecordGitterCommitRangeSize records the number of commits returned by a Gitter range operation.
func RecordGitterCommitRangeSize(operation string, commits int) {
if operation == "" {
operation = "unknown"
}
if commits < 0 {
commits = 0
}
GitterCommitRangeSizeCommits.WithLabelValues(operation).Observe(float64(commits))
}
6 changes: 6 additions & 0 deletions go/internal/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func TestMetricsRecording(t *testing.T) {
metrics.RecordRecovererTask("gcs_missing", metrics.TaskStatusSuccess)
metrics.RecordGitterCommitsScanned(42)
metrics.RecordGitterDataError(metrics.GitterErrorBadHash)
metrics.RecordGitterDataError(metrics.GitterErrorFetch)
metrics.GitterReposCached.Set(12)
metrics.RecordGitterCommitRangeSize("/affected-commits", 42)

req := httptest.NewRequest(http.MethodGet, "/metrics", nil)
rec := httptest.NewRecorder()
Expand Down Expand Up @@ -53,6 +56,9 @@ func TestMetricsRecording(t *testing.T) {
`osv_recoverer_processed_records_total{reason="gcs_missing",status="success"}`,
`osv_gitter_commits_scanned_total`,
`osv_gitter_data_errors_total{error_type="bad_hash"}`,
`osv_gitter_data_errors_total{error_type="fetch_error"}`,
`osv_gitter_repos_cached 12`,
`osv_gitter_commit_range_size_commits_bucket{operation="/affected-commits",le="50"} 1`,
}

for _, exp := range expectedStrings {
Expand Down
Loading