jev-logtriage 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jev_logtriage-0.1.0/LICENSE +21 -0
- jev_logtriage-0.1.0/PKG-INFO +146 -0
- jev_logtriage-0.1.0/README.md +126 -0
- jev_logtriage-0.1.0/jev_logtriage.egg-info/PKG-INFO +146 -0
- jev_logtriage-0.1.0/jev_logtriage.egg-info/SOURCES.txt +14 -0
- jev_logtriage-0.1.0/jev_logtriage.egg-info/dependency_links.txt +1 -0
- jev_logtriage-0.1.0/jev_logtriage.egg-info/entry_points.txt +2 -0
- jev_logtriage-0.1.0/jev_logtriage.egg-info/requires.txt +1 -0
- jev_logtriage-0.1.0/jev_logtriage.egg-info/top_level.txt +1 -0
- jev_logtriage-0.1.0/logtriage/__init__.py +33 -0
- jev_logtriage-0.1.0/logtriage/__main__.py +3 -0
- jev_logtriage-0.1.0/logtriage/cli.py +1252 -0
- jev_logtriage-0.1.0/logtriage/fixtures/demo.json +93 -0
- jev_logtriage-0.1.0/pyproject.toml +34 -0
- jev_logtriage-0.1.0/setup.cfg +4 -0
- jev_logtriage-0.1.0/tests/test_logtriage.py +290 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jonathan Yates
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jev-logtriage
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Jev decides whether a batch of logs is worth acting on
|
|
5
|
+
Author: Jonathan Yates
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/jyatesdotdev/jev-logtriage
|
|
8
|
+
Project-URL: Documentation, https://docs.typesafe.ai/patterns
|
|
9
|
+
Project-URL: Source, https://github.com/jyatesdotdev/jev-logtriage
|
|
10
|
+
Keywords: jev,typesafe,loki,observability,sre,logs
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: System :: Logging
|
|
14
|
+
Classifier: Topic :: System :: Monitoring
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: typesafe-sdk>=0.7.0
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<img src="docs/icon.svg" width="168" alt="A stack of log lines with one highlighted and punched through">
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<strong>jev-logtriage</strong><br>
|
|
27
|
+
<a href="https://docs.typesafe.ai/introduction/quickstart">Jev</a> decides whether a batch of logs is worth acting on.<br>
|
|
28
|
+
Your code keeps the thresholds. Nothing is executed.
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a href="https://github.com/jyatesdotdev/jev-logtriage/blob/main/LICENSE"><img alt="MIT" src="https://img.shields.io/badge/license-MIT-5a4a63?style=flat-square"></a>
|
|
33
|
+
<a href="https://docs.typesafe.ai/introduction"><img alt="Jev" src="https://img.shields.io/badge/TypeSafe-Jev-e551ba?style=flat-square"></a>
|
|
34
|
+
<a href="https://www.python.org/"><img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10+-3776ab?style=flat-square"></a>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p align="center">Independent. Not an official TypeSafe AI project.</p>
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
logs -> collapse -> jev (6 questions, one call) -> code gates
|
|
41
|
+
|
|
|
42
|
+
suppress | watch | review | notify | page
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Prometheus is good at conditions you already know how to write in PromQL. This is for the rest. Repeated benign warnings get `suppress`. A helm reconcile error and a failed ntfy push get `notify`. Low confidence never auto-acts. It goes to `review`.
|
|
46
|
+
|
|
47
|
+
## Try it
|
|
48
|
+
|
|
49
|
+
Needs [uv](https://docs.astral.sh/uv/) and a [TypeSafe API key](https://console.typesafe.ai/settings/keys). Loki is not required.
|
|
50
|
+
|
|
51
|
+
From this repo:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
55
|
+
uv run logtriage --demo
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Without cloning:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
62
|
+
uvx --from git+https://github.com/jyatesdotdev/jev-logtriage logtriage --demo
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`uv run` creates `.venv`, installs `uv.lock`, and runs the script. Python 3.10+ is enough.
|
|
66
|
+
|
|
67
|
+
Without uv:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install -r requirements.txt
|
|
71
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
72
|
+
python -m logtriage --demo
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`--demo` loads bundled fixtures (`logtriage/fixtures/demo.json`), a sanitized hour of homelab warn/error lines, and runs the same pipeline a Loki query would.
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
DECISION SEV PRIO CONF CATEGORY SOURCE
|
|
79
|
+
-----------------------------------------------------------------
|
|
80
|
+
notify 2.0 0.47 0.80 network alertmanager
|
|
81
|
+
notify 2.1 0.44 0.80 security forgejo-runner
|
|
82
|
+
notify 1.8 0.42 0.73 network helm-controller
|
|
83
|
+
notify 1.2 0.29 0.73 config authentik
|
|
84
|
+
watch 1.4 0.42 0.38 infra coredns
|
|
85
|
+
watch 0.6 0.19 0.54 expected_noise news-linker
|
|
86
|
+
suppress 0.6 0.17 0.54 expected_noise kube-state-metrics
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Numbers move a little from run to run. The gates do not.
|
|
90
|
+
|
|
91
|
+
## What Jev decides
|
|
92
|
+
|
|
93
|
+
One System One call per source. Question ids are not sent to the model. The instructions are.
|
|
94
|
+
|
|
95
|
+
| id | type | question |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `is_routine_noise` | noul | would an on-call engineer dismiss this? |
|
|
98
|
+
| `severity` | score | 0 routine to 3 critical |
|
|
99
|
+
| `impact_scope` | score | 0 one pod to 3 cluster-wide |
|
|
100
|
+
| `needs_action` | noul | should a human do something? |
|
|
101
|
+
| `auto_remediable` | noul | is there a safe, unambiguous automated fix? |
|
|
102
|
+
| `category` | choice | app_error, resource, infra, network, config, security, expected_noise |
|
|
103
|
+
|
|
104
|
+
Patterns from the [TypeSafe docs](https://docs.typesafe.ai/patterns):
|
|
105
|
+
|
|
106
|
+
- [Speculative fan-out](https://docs.typesafe.ai/patterns/fan-out). Ask all six up front. Ignore answers that do not apply.
|
|
107
|
+
- [Composite scoring](https://docs.typesafe.ai/patterns/composite-scoring). `priority = 0.60 * severity/3 + 0.40 * impact/3`. Weights live in code.
|
|
108
|
+
- [Confidence-gated routing](https://docs.typesafe.ai/patterns/confidence-routing). Below `--confidence-floor` (default 0.50) the decision is `review`.
|
|
109
|
+
|
|
110
|
+
Gates, in order:
|
|
111
|
+
|
|
112
|
+
1. `is_routine_noise >= 0.80` and severity below the page line → `suppress`
|
|
113
|
+
2. `needs_action < 0.50` → `watch`
|
|
114
|
+
3. min confidence below the floor → `review`
|
|
115
|
+
4. severity `>= 2.0` and priority `>= 0.70` → `page`
|
|
116
|
+
5. `auto_remediable >= 0.85` and a safe category → `auto_remediate_candidate`
|
|
117
|
+
6. otherwise → `notify`
|
|
118
|
+
|
|
119
|
+
Security is never an auto-remediation candidate. `auto_remediate_candidate` is a label. This repo does not restart pods, call webhooks, or page anyone.
|
|
120
|
+
|
|
121
|
+
## Loki
|
|
122
|
+
|
|
123
|
+
If you already run Loki, point the same script at it.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# kubectl port-forward -n monitoring svc/loki 3100:3100
|
|
127
|
+
uv run logtriage --since 1h --errors-only --exclude-app loki
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`--port-forward` will start that kubectl command if `http://127.0.0.1:3100/ready` fails.
|
|
131
|
+
|
|
132
|
+
A JSON report is written to `reports/triage-<timestamp>.json` unless you pass `--no-report`. It includes the exact state sent to Jev, the typed answers, and the rationale strings built from those answers. Jev does not generate prose.
|
|
133
|
+
|
|
134
|
+
## Limits
|
|
135
|
+
|
|
136
|
+
There is no memory across runs. The same coredns glob warning will be classified every time you invoke the script. Do not cron this until you add a fingerprint. That is intentional for v0.
|
|
137
|
+
|
|
138
|
+
`--fail-on page` exits 2 if any batch was paged, which is enough to hang off a CI job or a wrapper.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
uv run python -m unittest discover -s tests -t . -v
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/icon.svg" width="168" alt="A stack of log lines with one highlighted and punched through">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<strong>jev-logtriage</strong><br>
|
|
7
|
+
<a href="https://docs.typesafe.ai/introduction/quickstart">Jev</a> decides whether a batch of logs is worth acting on.<br>
|
|
8
|
+
Your code keeps the thresholds. Nothing is executed.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/jyatesdotdev/jev-logtriage/blob/main/LICENSE"><img alt="MIT" src="https://img.shields.io/badge/license-MIT-5a4a63?style=flat-square"></a>
|
|
13
|
+
<a href="https://docs.typesafe.ai/introduction"><img alt="Jev" src="https://img.shields.io/badge/TypeSafe-Jev-e551ba?style=flat-square"></a>
|
|
14
|
+
<a href="https://www.python.org/"><img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10+-3776ab?style=flat-square"></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">Independent. Not an official TypeSafe AI project.</p>
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
logs -> collapse -> jev (6 questions, one call) -> code gates
|
|
21
|
+
|
|
|
22
|
+
suppress | watch | review | notify | page
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Prometheus is good at conditions you already know how to write in PromQL. This is for the rest. Repeated benign warnings get `suppress`. A helm reconcile error and a failed ntfy push get `notify`. Low confidence never auto-acts. It goes to `review`.
|
|
26
|
+
|
|
27
|
+
## Try it
|
|
28
|
+
|
|
29
|
+
Needs [uv](https://docs.astral.sh/uv/) and a [TypeSafe API key](https://console.typesafe.ai/settings/keys). Loki is not required.
|
|
30
|
+
|
|
31
|
+
From this repo:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
35
|
+
uv run logtriage --demo
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Without cloning:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
42
|
+
uvx --from git+https://github.com/jyatesdotdev/jev-logtriage logtriage --demo
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`uv run` creates `.venv`, installs `uv.lock`, and runs the script. Python 3.10+ is enough.
|
|
46
|
+
|
|
47
|
+
Without uv:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install -r requirements.txt
|
|
51
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
52
|
+
python -m logtriage --demo
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`--demo` loads bundled fixtures (`logtriage/fixtures/demo.json`), a sanitized hour of homelab warn/error lines, and runs the same pipeline a Loki query would.
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
DECISION SEV PRIO CONF CATEGORY SOURCE
|
|
59
|
+
-----------------------------------------------------------------
|
|
60
|
+
notify 2.0 0.47 0.80 network alertmanager
|
|
61
|
+
notify 2.1 0.44 0.80 security forgejo-runner
|
|
62
|
+
notify 1.8 0.42 0.73 network helm-controller
|
|
63
|
+
notify 1.2 0.29 0.73 config authentik
|
|
64
|
+
watch 1.4 0.42 0.38 infra coredns
|
|
65
|
+
watch 0.6 0.19 0.54 expected_noise news-linker
|
|
66
|
+
suppress 0.6 0.17 0.54 expected_noise kube-state-metrics
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Numbers move a little from run to run. The gates do not.
|
|
70
|
+
|
|
71
|
+
## What Jev decides
|
|
72
|
+
|
|
73
|
+
One System One call per source. Question ids are not sent to the model. The instructions are.
|
|
74
|
+
|
|
75
|
+
| id | type | question |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| `is_routine_noise` | noul | would an on-call engineer dismiss this? |
|
|
78
|
+
| `severity` | score | 0 routine to 3 critical |
|
|
79
|
+
| `impact_scope` | score | 0 one pod to 3 cluster-wide |
|
|
80
|
+
| `needs_action` | noul | should a human do something? |
|
|
81
|
+
| `auto_remediable` | noul | is there a safe, unambiguous automated fix? |
|
|
82
|
+
| `category` | choice | app_error, resource, infra, network, config, security, expected_noise |
|
|
83
|
+
|
|
84
|
+
Patterns from the [TypeSafe docs](https://docs.typesafe.ai/patterns):
|
|
85
|
+
|
|
86
|
+
- [Speculative fan-out](https://docs.typesafe.ai/patterns/fan-out). Ask all six up front. Ignore answers that do not apply.
|
|
87
|
+
- [Composite scoring](https://docs.typesafe.ai/patterns/composite-scoring). `priority = 0.60 * severity/3 + 0.40 * impact/3`. Weights live in code.
|
|
88
|
+
- [Confidence-gated routing](https://docs.typesafe.ai/patterns/confidence-routing). Below `--confidence-floor` (default 0.50) the decision is `review`.
|
|
89
|
+
|
|
90
|
+
Gates, in order:
|
|
91
|
+
|
|
92
|
+
1. `is_routine_noise >= 0.80` and severity below the page line → `suppress`
|
|
93
|
+
2. `needs_action < 0.50` → `watch`
|
|
94
|
+
3. min confidence below the floor → `review`
|
|
95
|
+
4. severity `>= 2.0` and priority `>= 0.70` → `page`
|
|
96
|
+
5. `auto_remediable >= 0.85` and a safe category → `auto_remediate_candidate`
|
|
97
|
+
6. otherwise → `notify`
|
|
98
|
+
|
|
99
|
+
Security is never an auto-remediation candidate. `auto_remediate_candidate` is a label. This repo does not restart pods, call webhooks, or page anyone.
|
|
100
|
+
|
|
101
|
+
## Loki
|
|
102
|
+
|
|
103
|
+
If you already run Loki, point the same script at it.
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# kubectl port-forward -n monitoring svc/loki 3100:3100
|
|
107
|
+
uv run logtriage --since 1h --errors-only --exclude-app loki
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`--port-forward` will start that kubectl command if `http://127.0.0.1:3100/ready` fails.
|
|
111
|
+
|
|
112
|
+
A JSON report is written to `reports/triage-<timestamp>.json` unless you pass `--no-report`. It includes the exact state sent to Jev, the typed answers, and the rationale strings built from those answers. Jev does not generate prose.
|
|
113
|
+
|
|
114
|
+
## Limits
|
|
115
|
+
|
|
116
|
+
There is no memory across runs. The same coredns glob warning will be classified every time you invoke the script. Do not cron this until you add a fingerprint. That is intentional for v0.
|
|
117
|
+
|
|
118
|
+
`--fail-on page` exits 2 if any batch was paged, which is enough to hang off a CI job or a wrapper.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
uv run python -m unittest discover -s tests -t . -v
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jev-logtriage
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Jev decides whether a batch of logs is worth acting on
|
|
5
|
+
Author: Jonathan Yates
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/jyatesdotdev/jev-logtriage
|
|
8
|
+
Project-URL: Documentation, https://docs.typesafe.ai/patterns
|
|
9
|
+
Project-URL: Source, https://github.com/jyatesdotdev/jev-logtriage
|
|
10
|
+
Keywords: jev,typesafe,loki,observability,sre,logs
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: System :: Logging
|
|
14
|
+
Classifier: Topic :: System :: Monitoring
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: typesafe-sdk>=0.7.0
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<img src="docs/icon.svg" width="168" alt="A stack of log lines with one highlighted and punched through">
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<strong>jev-logtriage</strong><br>
|
|
27
|
+
<a href="https://docs.typesafe.ai/introduction/quickstart">Jev</a> decides whether a batch of logs is worth acting on.<br>
|
|
28
|
+
Your code keeps the thresholds. Nothing is executed.
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a href="https://github.com/jyatesdotdev/jev-logtriage/blob/main/LICENSE"><img alt="MIT" src="https://img.shields.io/badge/license-MIT-5a4a63?style=flat-square"></a>
|
|
33
|
+
<a href="https://docs.typesafe.ai/introduction"><img alt="Jev" src="https://img.shields.io/badge/TypeSafe-Jev-e551ba?style=flat-square"></a>
|
|
34
|
+
<a href="https://www.python.org/"><img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10+-3776ab?style=flat-square"></a>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p align="center">Independent. Not an official TypeSafe AI project.</p>
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
logs -> collapse -> jev (6 questions, one call) -> code gates
|
|
41
|
+
|
|
|
42
|
+
suppress | watch | review | notify | page
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Prometheus is good at conditions you already know how to write in PromQL. This is for the rest. Repeated benign warnings get `suppress`. A helm reconcile error and a failed ntfy push get `notify`. Low confidence never auto-acts. It goes to `review`.
|
|
46
|
+
|
|
47
|
+
## Try it
|
|
48
|
+
|
|
49
|
+
Needs [uv](https://docs.astral.sh/uv/) and a [TypeSafe API key](https://console.typesafe.ai/settings/keys). Loki is not required.
|
|
50
|
+
|
|
51
|
+
From this repo:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
55
|
+
uv run logtriage --demo
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Without cloning:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
62
|
+
uvx --from git+https://github.com/jyatesdotdev/jev-logtriage logtriage --demo
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`uv run` creates `.venv`, installs `uv.lock`, and runs the script. Python 3.10+ is enough.
|
|
66
|
+
|
|
67
|
+
Without uv:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install -r requirements.txt
|
|
71
|
+
export TYPESAFE_API_KEY=apikey_...
|
|
72
|
+
python -m logtriage --demo
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`--demo` loads bundled fixtures (`logtriage/fixtures/demo.json`), a sanitized hour of homelab warn/error lines, and runs the same pipeline a Loki query would.
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
DECISION SEV PRIO CONF CATEGORY SOURCE
|
|
79
|
+
-----------------------------------------------------------------
|
|
80
|
+
notify 2.0 0.47 0.80 network alertmanager
|
|
81
|
+
notify 2.1 0.44 0.80 security forgejo-runner
|
|
82
|
+
notify 1.8 0.42 0.73 network helm-controller
|
|
83
|
+
notify 1.2 0.29 0.73 config authentik
|
|
84
|
+
watch 1.4 0.42 0.38 infra coredns
|
|
85
|
+
watch 0.6 0.19 0.54 expected_noise news-linker
|
|
86
|
+
suppress 0.6 0.17 0.54 expected_noise kube-state-metrics
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Numbers move a little from run to run. The gates do not.
|
|
90
|
+
|
|
91
|
+
## What Jev decides
|
|
92
|
+
|
|
93
|
+
One System One call per source. Question ids are not sent to the model. The instructions are.
|
|
94
|
+
|
|
95
|
+
| id | type | question |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `is_routine_noise` | noul | would an on-call engineer dismiss this? |
|
|
98
|
+
| `severity` | score | 0 routine to 3 critical |
|
|
99
|
+
| `impact_scope` | score | 0 one pod to 3 cluster-wide |
|
|
100
|
+
| `needs_action` | noul | should a human do something? |
|
|
101
|
+
| `auto_remediable` | noul | is there a safe, unambiguous automated fix? |
|
|
102
|
+
| `category` | choice | app_error, resource, infra, network, config, security, expected_noise |
|
|
103
|
+
|
|
104
|
+
Patterns from the [TypeSafe docs](https://docs.typesafe.ai/patterns):
|
|
105
|
+
|
|
106
|
+
- [Speculative fan-out](https://docs.typesafe.ai/patterns/fan-out). Ask all six up front. Ignore answers that do not apply.
|
|
107
|
+
- [Composite scoring](https://docs.typesafe.ai/patterns/composite-scoring). `priority = 0.60 * severity/3 + 0.40 * impact/3`. Weights live in code.
|
|
108
|
+
- [Confidence-gated routing](https://docs.typesafe.ai/patterns/confidence-routing). Below `--confidence-floor` (default 0.50) the decision is `review`.
|
|
109
|
+
|
|
110
|
+
Gates, in order:
|
|
111
|
+
|
|
112
|
+
1. `is_routine_noise >= 0.80` and severity below the page line → `suppress`
|
|
113
|
+
2. `needs_action < 0.50` → `watch`
|
|
114
|
+
3. min confidence below the floor → `review`
|
|
115
|
+
4. severity `>= 2.0` and priority `>= 0.70` → `page`
|
|
116
|
+
5. `auto_remediable >= 0.85` and a safe category → `auto_remediate_candidate`
|
|
117
|
+
6. otherwise → `notify`
|
|
118
|
+
|
|
119
|
+
Security is never an auto-remediation candidate. `auto_remediate_candidate` is a label. This repo does not restart pods, call webhooks, or page anyone.
|
|
120
|
+
|
|
121
|
+
## Loki
|
|
122
|
+
|
|
123
|
+
If you already run Loki, point the same script at it.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# kubectl port-forward -n monitoring svc/loki 3100:3100
|
|
127
|
+
uv run logtriage --since 1h --errors-only --exclude-app loki
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`--port-forward` will start that kubectl command if `http://127.0.0.1:3100/ready` fails.
|
|
131
|
+
|
|
132
|
+
A JSON report is written to `reports/triage-<timestamp>.json` unless you pass `--no-report`. It includes the exact state sent to Jev, the typed answers, and the rationale strings built from those answers. Jev does not generate prose.
|
|
133
|
+
|
|
134
|
+
## Limits
|
|
135
|
+
|
|
136
|
+
There is no memory across runs. The same coredns glob warning will be classified every time you invoke the script. Do not cron this until you add a fingerprint. That is intentional for v0.
|
|
137
|
+
|
|
138
|
+
`--fail-on page` exits 2 if any batch was paged, which is enough to hang off a CI job or a wrapper.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
uv run python -m unittest discover -s tests -t . -v
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
jev_logtriage.egg-info/PKG-INFO
|
|
5
|
+
jev_logtriage.egg-info/SOURCES.txt
|
|
6
|
+
jev_logtriage.egg-info/dependency_links.txt
|
|
7
|
+
jev_logtriage.egg-info/entry_points.txt
|
|
8
|
+
jev_logtriage.egg-info/requires.txt
|
|
9
|
+
jev_logtriage.egg-info/top_level.txt
|
|
10
|
+
logtriage/__init__.py
|
|
11
|
+
logtriage/__main__.py
|
|
12
|
+
logtriage/cli.py
|
|
13
|
+
logtriage/fixtures/demo.json
|
|
14
|
+
tests/test_logtriage.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
typesafe-sdk>=0.7.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
logtriage
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Jev decides whether a batch of logs is worth acting on."""
|
|
2
|
+
|
|
3
|
+
from logtriage.cli import (
|
|
4
|
+
Batch,
|
|
5
|
+
Config,
|
|
6
|
+
Pattern,
|
|
7
|
+
build_batches,
|
|
8
|
+
build_selector,
|
|
9
|
+
build_state,
|
|
10
|
+
decide,
|
|
11
|
+
detect_level,
|
|
12
|
+
load_api_key,
|
|
13
|
+
load_demo_streams,
|
|
14
|
+
main,
|
|
15
|
+
normalize_line,
|
|
16
|
+
parse_duration,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"Batch",
|
|
21
|
+
"Config",
|
|
22
|
+
"Pattern",
|
|
23
|
+
"build_batches",
|
|
24
|
+
"build_selector",
|
|
25
|
+
"build_state",
|
|
26
|
+
"decide",
|
|
27
|
+
"detect_level",
|
|
28
|
+
"load_api_key",
|
|
29
|
+
"load_demo_streams",
|
|
30
|
+
"main",
|
|
31
|
+
"normalize_line",
|
|
32
|
+
"parse_duration",
|
|
33
|
+
]
|