phlo-loki 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.
- phlo_loki-0.1.0/PKG-INFO +16 -0
- phlo_loki-0.1.0/README.md +55 -0
- phlo_loki-0.1.0/pyproject.toml +49 -0
- phlo_loki-0.1.0/setup.cfg +4 -0
- phlo_loki-0.1.0/src/phlo_loki/__init__.py +0 -0
- phlo_loki-0.1.0/src/phlo_loki/loki-config.yml +40 -0
- phlo_loki-0.1.0/src/phlo_loki/observatory_assets/README.txt +1 -0
- phlo_loki-0.1.0/src/phlo_loki/observatory_plugin.py +40 -0
- phlo_loki-0.1.0/src/phlo_loki/plugin.py +29 -0
- phlo_loki-0.1.0/src/phlo_loki/service.yaml +46 -0
- phlo_loki-0.1.0/src/phlo_loki.egg-info/PKG-INFO +16 -0
- phlo_loki-0.1.0/src/phlo_loki.egg-info/SOURCES.txt +16 -0
- phlo_loki-0.1.0/src/phlo_loki.egg-info/dependency_links.txt +1 -0
- phlo_loki-0.1.0/src/phlo_loki.egg-info/entry_points.txt +5 -0
- phlo_loki-0.1.0/src/phlo_loki.egg-info/requires.txt +7 -0
- phlo_loki-0.1.0/src/phlo_loki.egg-info/top_level.txt +1 -0
- phlo_loki-0.1.0/tests/test_integration_loki.py +24 -0
- phlo_loki-0.1.0/tests/test_loki_plugin.py +19 -0
phlo_loki-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: phlo-loki
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: loki service plugin for Phlo
|
|
5
|
+
Author-email: Phlo Team <team@phlo.dev>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/plain
|
|
9
|
+
Requires-Dist: phlo>=0.1.0
|
|
10
|
+
Requires-Dist: phlo-observatory>=0.1.0
|
|
11
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
14
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
15
|
+
|
|
16
|
+
loki service plugin for Phlo.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# phlo-loki
|
|
2
|
+
|
|
3
|
+
Loki log aggregation for Phlo.
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
Log aggregation and querying service. Receives logs from Alloy and provides log search in Grafana.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install phlo-loki
|
|
13
|
+
# or
|
|
14
|
+
phlo plugin install loki
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Profile
|
|
18
|
+
|
|
19
|
+
Part of the `observability` profile.
|
|
20
|
+
|
|
21
|
+
## Configuration
|
|
22
|
+
|
|
23
|
+
| Variable | Default | Description |
|
|
24
|
+
| -------------- | ------- | ------------- |
|
|
25
|
+
| `LOKI_PORT` | `3100` | Loki API port |
|
|
26
|
+
| `LOKI_VERSION` | `3.2.1` | Loki version |
|
|
27
|
+
|
|
28
|
+
## Auto-Configuration
|
|
29
|
+
|
|
30
|
+
This package is **fully auto-configured**:
|
|
31
|
+
|
|
32
|
+
| Feature | How It Works |
|
|
33
|
+
| ---------------------- | ---------------------------------------------- |
|
|
34
|
+
| **Metrics Labels** | Exposes Loki metrics for Prometheus |
|
|
35
|
+
| **Grafana Datasource** | Pre-configured in Grafana as "Loki" datasource |
|
|
36
|
+
| **Alloy Integration** | Receives logs from Alloy |
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Start with observability profile
|
|
42
|
+
phlo services start --profile observability
|
|
43
|
+
|
|
44
|
+
# Or start individually
|
|
45
|
+
phlo services start --service loki
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Endpoints
|
|
49
|
+
|
|
50
|
+
- **API**: `http://localhost:3100`
|
|
51
|
+
- **Ready**: `http://localhost:3100/ready`
|
|
52
|
+
|
|
53
|
+
## Entry Points
|
|
54
|
+
|
|
55
|
+
- `phlo.plugins.services` - Provides `LokiServicePlugin`
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=45", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "phlo-loki"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "loki service plugin for Phlo"
|
|
9
|
+
readme = {text = "loki service plugin for Phlo.", content-type = "text/plain"}
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Phlo Team", email = "team@phlo.dev"},
|
|
13
|
+
]
|
|
14
|
+
license = {text = "MIT"}
|
|
15
|
+
dependencies = [
|
|
16
|
+
"phlo>=0.1.0",
|
|
17
|
+
"phlo-observatory>=0.1.0",
|
|
18
|
+
"pyyaml>=6.0.1",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = [
|
|
23
|
+
"pytest>=7.0",
|
|
24
|
+
"ruff>=0.1.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.entry-points."phlo.plugins.services"]
|
|
28
|
+
loki = "phlo_loki.plugin:LokiServicePlugin"
|
|
29
|
+
|
|
30
|
+
[project.entry-points."phlo.plugins.observatory"]
|
|
31
|
+
loki = "phlo_loki.observatory_plugin:LokiObservatoryExtension"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools]
|
|
34
|
+
package-dir = {"" = "src"}
|
|
35
|
+
include-package-data = true
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages.find]
|
|
38
|
+
where = ["src"]
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.package-data]
|
|
41
|
+
phlo_loki = [
|
|
42
|
+
"service.yaml",
|
|
43
|
+
"loki-config.yml",
|
|
44
|
+
"observatory_assets/*",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 100
|
|
49
|
+
target-version = "py311"
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
auth_enabled: false
|
|
2
|
+
|
|
3
|
+
server:
|
|
4
|
+
http_listen_port: 3100
|
|
5
|
+
grpc_listen_port: 9096
|
|
6
|
+
|
|
7
|
+
common:
|
|
8
|
+
instance_addr: 127.0.0.1
|
|
9
|
+
path_prefix: /loki
|
|
10
|
+
storage:
|
|
11
|
+
filesystem:
|
|
12
|
+
chunks_directory: /loki/chunks
|
|
13
|
+
rules_directory: /loki/rules
|
|
14
|
+
replication_factor: 1
|
|
15
|
+
ring:
|
|
16
|
+
kvstore:
|
|
17
|
+
store: inmemory
|
|
18
|
+
|
|
19
|
+
query_range:
|
|
20
|
+
results_cache:
|
|
21
|
+
cache:
|
|
22
|
+
embedded_cache:
|
|
23
|
+
enabled: true
|
|
24
|
+
max_size_mb: 100
|
|
25
|
+
|
|
26
|
+
schema_config:
|
|
27
|
+
configs:
|
|
28
|
+
- from: 2020-10-24
|
|
29
|
+
store: tsdb
|
|
30
|
+
object_store: filesystem
|
|
31
|
+
schema: v13
|
|
32
|
+
index:
|
|
33
|
+
prefix: index_
|
|
34
|
+
period: 24h
|
|
35
|
+
|
|
36
|
+
ruler:
|
|
37
|
+
alertmanager_url: http://localhost:9093
|
|
38
|
+
|
|
39
|
+
analytics:
|
|
40
|
+
reporting_enabled: false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Observatory assets for phlo-loki.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Observatory extension for Loki logs UI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib import resources
|
|
6
|
+
from importlib.abc import Traversable
|
|
7
|
+
|
|
8
|
+
from phlo.plugins import PluginMetadata
|
|
9
|
+
from phlo_observatory import ObservatoryExtensionPlugin
|
|
10
|
+
from phlo_observatory.manifest import (
|
|
11
|
+
ObservatoryExtensionCompatibility,
|
|
12
|
+
ObservatoryExtensionManifest,
|
|
13
|
+
ObservatoryExtensionNavItem,
|
|
14
|
+
ObservatoryExtensionUI,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class LokiObservatoryExtension(ObservatoryExtensionPlugin):
|
|
19
|
+
"""Observatory extension metadata for Loki logs UI."""
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def metadata(self) -> PluginMetadata:
|
|
23
|
+
return PluginMetadata(
|
|
24
|
+
name="loki",
|
|
25
|
+
version="0.1.0",
|
|
26
|
+
description="Observatory UI extension for logs",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def manifest(self) -> ObservatoryExtensionManifest:
|
|
31
|
+
return ObservatoryExtensionManifest(
|
|
32
|
+
name="loki",
|
|
33
|
+
version="0.1.0",
|
|
34
|
+
compat=ObservatoryExtensionCompatibility(observatory_min="0.1.0"),
|
|
35
|
+
ui=ObservatoryExtensionUI(nav=[ObservatoryExtensionNavItem(title="Logs", to="/logs")]),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def asset_root(self) -> Traversable:
|
|
40
|
+
return resources.files("phlo_loki").joinpath("observatory_assets")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Loki service plugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib import resources
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import yaml
|
|
9
|
+
|
|
10
|
+
from phlo.plugins import PluginMetadata, ServicePlugin
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LokiServicePlugin(ServicePlugin):
|
|
14
|
+
"""Service plugin for loki."""
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def metadata(self) -> PluginMetadata:
|
|
18
|
+
return PluginMetadata(
|
|
19
|
+
name="loki",
|
|
20
|
+
version="0.1.0",
|
|
21
|
+
description="Log aggregation and querying",
|
|
22
|
+
author="Phlo Team",
|
|
23
|
+
tags=["observability", "logs"],
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def service_definition(self) -> dict[str, Any]:
|
|
28
|
+
service_path = resources.files("phlo_loki").joinpath("service.yaml")
|
|
29
|
+
return yaml.safe_load(service_path.read_text(encoding="utf-8"))
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: loki
|
|
2
|
+
description: Log aggregation and querying
|
|
3
|
+
category: observability
|
|
4
|
+
default: false
|
|
5
|
+
profile: observability
|
|
6
|
+
|
|
7
|
+
image: grafana/loki:${LOKI_VERSION:-3.2.1}
|
|
8
|
+
|
|
9
|
+
compose:
|
|
10
|
+
restart: unless-stopped
|
|
11
|
+
user: "0"
|
|
12
|
+
labels:
|
|
13
|
+
phlo.metrics.enabled: "true"
|
|
14
|
+
phlo.metrics.port: "loki:3100"
|
|
15
|
+
phlo.metrics.path: "/metrics"
|
|
16
|
+
command: -config.file=/etc/loki/loki-config.yml
|
|
17
|
+
ports:
|
|
18
|
+
- "${LOKI_PORT:-3100}:3100"
|
|
19
|
+
volumes:
|
|
20
|
+
- ./loki:/etc/loki:ro
|
|
21
|
+
- ./volumes/loki:/loki
|
|
22
|
+
healthcheck:
|
|
23
|
+
test:
|
|
24
|
+
[
|
|
25
|
+
"CMD",
|
|
26
|
+
"wget",
|
|
27
|
+
"--quiet",
|
|
28
|
+
"--tries=1",
|
|
29
|
+
"--spider",
|
|
30
|
+
"http://localhost:3100/ready",
|
|
31
|
+
]
|
|
32
|
+
interval: 10s
|
|
33
|
+
timeout: 5s
|
|
34
|
+
retries: 5
|
|
35
|
+
|
|
36
|
+
env_vars:
|
|
37
|
+
LOKI_VERSION:
|
|
38
|
+
default: "3.2.1"
|
|
39
|
+
description: Loki version
|
|
40
|
+
LOKI_PORT:
|
|
41
|
+
default: 3100
|
|
42
|
+
description: Loki API port
|
|
43
|
+
|
|
44
|
+
files:
|
|
45
|
+
- source: loki-config.yml
|
|
46
|
+
dest: loki/loki-config.yml
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: phlo-loki
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: loki service plugin for Phlo
|
|
5
|
+
Author-email: Phlo Team <team@phlo.dev>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/plain
|
|
9
|
+
Requires-Dist: phlo>=0.1.0
|
|
10
|
+
Requires-Dist: phlo-observatory>=0.1.0
|
|
11
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
14
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
15
|
+
|
|
16
|
+
loki service plugin for Phlo.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/phlo_loki/__init__.py
|
|
4
|
+
src/phlo_loki/loki-config.yml
|
|
5
|
+
src/phlo_loki/observatory_plugin.py
|
|
6
|
+
src/phlo_loki/plugin.py
|
|
7
|
+
src/phlo_loki/service.yaml
|
|
8
|
+
src/phlo_loki.egg-info/PKG-INFO
|
|
9
|
+
src/phlo_loki.egg-info/SOURCES.txt
|
|
10
|
+
src/phlo_loki.egg-info/dependency_links.txt
|
|
11
|
+
src/phlo_loki.egg-info/entry_points.txt
|
|
12
|
+
src/phlo_loki.egg-info/requires.txt
|
|
13
|
+
src/phlo_loki.egg-info/top_level.txt
|
|
14
|
+
src/phlo_loki/observatory_assets/README.txt
|
|
15
|
+
tests/test_integration_loki.py
|
|
16
|
+
tests/test_loki_plugin.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
phlo_loki
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Integration tests for phlo-loki."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
pytestmark = pytest.mark.integration
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_loki_plugin_initializes():
|
|
9
|
+
"""Test that Loki plugin can be instantiated."""
|
|
10
|
+
from phlo_loki.plugin import LokiServicePlugin
|
|
11
|
+
|
|
12
|
+
plugin = LokiServicePlugin()
|
|
13
|
+
assert plugin is not None
|
|
14
|
+
assert plugin.metadata.name == "loki"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_loki_service_definition():
|
|
18
|
+
"""Test that service definition can be loaded."""
|
|
19
|
+
from phlo_loki.plugin import LokiServicePlugin
|
|
20
|
+
|
|
21
|
+
plugin = LokiServicePlugin()
|
|
22
|
+
service_def = plugin.service_definition
|
|
23
|
+
|
|
24
|
+
assert isinstance(service_def, dict)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Tests for Loki service plugin."""
|
|
2
|
+
|
|
3
|
+
from phlo_loki.plugin import LokiServicePlugin
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_loki_service_definition():
|
|
7
|
+
plugin = LokiServicePlugin()
|
|
8
|
+
defn = plugin.service_definition
|
|
9
|
+
|
|
10
|
+
assert defn["name"] == "loki"
|
|
11
|
+
assert defn["profile"] == "observability"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_loki_plugin_metadata():
|
|
15
|
+
plugin = LokiServicePlugin()
|
|
16
|
+
meta = plugin.metadata
|
|
17
|
+
|
|
18
|
+
assert meta.name == "loki"
|
|
19
|
+
assert "observability" in meta.tags
|