pico

created pr with 35.1 on 2024-11-15T15:03:31Z · by c8ef7d19
added 35.2 on 2024-11-23T03:34:44Z · by c8ef7d19
1: 77aaa29 ! 1: 8d56535 reactor(metric-drain): use caddy json format
-: ------- > 2: a336041 wip
-: ------- > 3: 7ae45b3 chore: wrap
-: ------- > 4: bfa5c4f done
added 35.3 on 2024-11-27T20:17:20Z · by c8ef7d19
1: 8d56535 < -: ------- reactor(metric-drain): use caddy json format
-: ------- > 1: c7eeb12 reactor(metric-drain): use caddy access logs
2: a336041 < -: ------- wip
3: 7ae45b3 < -: ------- chore: wrap
4: bfa5c4f < -: ------- done
added 35.4 on 2024-11-27T20:18:31Z · by c8ef7d19
1: c7eeb12 ! 1: 4e0839a reactor(metric-drain): use caddy access logs
changed status to accepted on 2024-11-28T03:03:53Z · by c8ef7d19
cmds
checkout latest patchset:
ssh pr.pico.sh print 35 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 35.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 35
set PR to open (enables RSS notifications):
ssh pr.pico.sh pr open 35
set PR to draft (stops RSS notifications):
ssh pr.pico.sh pr draft 35
+29 -0 auth/api.go #
......@@ -22,6 +22,7 @@ import (
2222 "github.com/picosh/pico/db/postgres"
2323 "github.com/picosh/pico/shared"
2424 "github.com/picosh/utils"
25+ "github.com/picosh/utils/pipe"
2526 "github.com/picosh/utils/pipe/metrics"
2627 )
2728
......@@ -662,6 +663,30 @@ func deserializeCaddyAccessLog(dbpool db.DB, access *CaddyAccessLog) (*db.Analyt
662663 }, nil
663664 }
664665
666+func containerDrainSub(ctx context.Context, logger *slog.Logger) {
667+ drain := pipe.NewReconnectReadWriteCloser(
668+ ctx,
669+ logger,
670+ shared.NewPicoPipeClient(),
671+ "container logs",
672+ "sub container-drain -k",
673+ 100,
674+ -1,
675+ )
676+
677+ fmt.Println("WTFFFFFF")
678+ scanner := bufio.NewScanner(drain)
679+ for scanner.Scan() {
680+ line := scanner.Text()
681+ fmt.Println("HMMMM", line)
682+ if strings.Contains(line, "http.log.access") {
683+ clean := strings.TrimSpace(line)
684+ fmt.Println("LINE", clean)
685+ // TODO: send to metric drain
686+ }
687+ }
688+}
689+
665690 func metricDrainSub(ctx context.Context, dbpool db.DB, logger *slog.Logger, secret string) {
666691 drain := metrics.ReconnectReadMetrics(
667692 ctx,
......@@ -699,6 +724,7 @@ func metricDrainSub(ctx context.Context, dbpool db.DB, logger *slog.Logger, secr
699724 logger.Error("could not insert visit record", "err", err)
700725 }
701726 }
727+ fmt.Println("DROPINNGGGGGGG")
702728 }
703729
704730 func authMux(apiConfig *shared.ApiConfig) *http.ServeMux {
......@@ -769,6 +795,9 @@ func StartApiServer() {
769795
770796 // gather metrics in the auth service
771797 go metricDrainSub(ctx, db, logger, cfg.Secret)
798+ // convert container logs to access logs
799+ // go containerDrainSub(ctx, logger)
800+
772801 defer ctx.Done()
773802
774803 apiConfig := &shared.ApiConfig{
+0 -0 test.txt #
Binaries are not rendered as diffs.
Back to top