phlo-postgres 0.1.0__py3-none-any.whl
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_postgres/__init__.py +7 -0
- phlo_postgres/exporter_service.yaml +39 -0
- phlo_postgres/plugin.py +47 -0
- phlo_postgres/service.yaml +60 -0
- phlo_postgres/settings.py +34 -0
- phlo_postgres-0.1.0.dist-info/METADATA +15 -0
- phlo_postgres-0.1.0.dist-info/RECORD +10 -0
- phlo_postgres-0.1.0.dist-info/WHEEL +5 -0
- phlo_postgres-0.1.0.dist-info/entry_points.txt +3 -0
- phlo_postgres-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: postgres-exporter
|
|
2
|
+
description: Prometheus exporter for PostgreSQL metrics
|
|
3
|
+
category: observability
|
|
4
|
+
default: false
|
|
5
|
+
profile: observability
|
|
6
|
+
|
|
7
|
+
image: quay.io/prometheuscommunity/postgres-exporter:v0.15.0
|
|
8
|
+
|
|
9
|
+
depends_on:
|
|
10
|
+
- postgres
|
|
11
|
+
|
|
12
|
+
compose:
|
|
13
|
+
restart: unless-stopped
|
|
14
|
+
labels:
|
|
15
|
+
phlo.metrics.enabled: "true"
|
|
16
|
+
phlo.metrics.port: "postgres-exporter:9187"
|
|
17
|
+
phlo.metrics.path: "/metrics"
|
|
18
|
+
environment:
|
|
19
|
+
DATA_SOURCE_NAME: postgresql://${POSTGRES_USER:-phlo}:${POSTGRES_PASSWORD:-phlo}@postgres:5432/${POSTGRES_DB:-phlo}?sslmode=disable
|
|
20
|
+
ports:
|
|
21
|
+
- "${POSTGRES_EXPORTER_PORT:-9187}:9187"
|
|
22
|
+
healthcheck:
|
|
23
|
+
test:
|
|
24
|
+
[
|
|
25
|
+
"CMD",
|
|
26
|
+
"wget",
|
|
27
|
+
"--quiet",
|
|
28
|
+
"--tries=1",
|
|
29
|
+
"--spider",
|
|
30
|
+
"http://localhost:9187/metrics",
|
|
31
|
+
]
|
|
32
|
+
interval: 10s
|
|
33
|
+
timeout: 5s
|
|
34
|
+
retries: 5
|
|
35
|
+
|
|
36
|
+
env_vars:
|
|
37
|
+
POSTGRES_EXPORTER_PORT:
|
|
38
|
+
default: 9187
|
|
39
|
+
description: Postgres exporter metrics port
|
phlo_postgres/plugin.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Postgres service plugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib import resources
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import yaml
|
|
9
|
+
from phlo.plugins import PluginMetadata, ServicePlugin
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class PostgresServicePlugin(ServicePlugin):
|
|
13
|
+
"""Service plugin for Postgres."""
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def metadata(self) -> PluginMetadata:
|
|
17
|
+
return PluginMetadata(
|
|
18
|
+
name="postgres",
|
|
19
|
+
version="0.1.0",
|
|
20
|
+
description="PostgreSQL database for metadata and operational storage",
|
|
21
|
+
author="Phlo Team",
|
|
22
|
+
tags=["core", "database", "postgres"],
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def service_definition(self) -> dict[str, Any]:
|
|
27
|
+
service_path = resources.files("phlo_postgres").joinpath("service.yaml")
|
|
28
|
+
return yaml.safe_load(service_path.read_text(encoding="utf-8"))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class PostgresExporterServicePlugin(ServicePlugin):
|
|
32
|
+
"""Service plugin for Postgres Prometheus exporter."""
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def metadata(self) -> PluginMetadata:
|
|
36
|
+
return PluginMetadata(
|
|
37
|
+
name="postgres-exporter",
|
|
38
|
+
version="0.1.0",
|
|
39
|
+
description="Prometheus exporter for PostgreSQL metrics",
|
|
40
|
+
author="Phlo Team",
|
|
41
|
+
tags=["observability", "metrics", "postgres"],
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def service_definition(self) -> dict[str, Any]:
|
|
46
|
+
service_path = resources.files("phlo_postgres").joinpath("exporter_service.yaml")
|
|
47
|
+
return yaml.safe_load(service_path.read_text(encoding="utf-8"))
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: postgres
|
|
2
|
+
description: PostgreSQL database for metadata and operational storage
|
|
3
|
+
category: core
|
|
4
|
+
default: true
|
|
5
|
+
|
|
6
|
+
image: postgres:16-alpine
|
|
7
|
+
|
|
8
|
+
compose:
|
|
9
|
+
restart: unless-stopped
|
|
10
|
+
labels:
|
|
11
|
+
phlo.metrics.enabled: "false"
|
|
12
|
+
phlo.grafana.datasource: "true"
|
|
13
|
+
phlo.grafana.datasource.type: "postgres"
|
|
14
|
+
phlo.grafana.datasource.name: "PostgreSQL"
|
|
15
|
+
phlo.grafana.datasource.url: "postgres:5432"
|
|
16
|
+
phlo.grafana.datasource.database: "${POSTGRES_DB:-phlo}"
|
|
17
|
+
environment:
|
|
18
|
+
POSTGRES_USER: ${POSTGRES_USER:-phlo}
|
|
19
|
+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-phlo}
|
|
20
|
+
POSTGRES_DB: ${POSTGRES_DB:-phlo}
|
|
21
|
+
# SSL/TLS
|
|
22
|
+
POSTGRES_SSL_MODE: ${POSTGRES_SSL_MODE:-prefer}
|
|
23
|
+
ports:
|
|
24
|
+
- "${POSTGRES_PORT:-5432}:5432"
|
|
25
|
+
volumes:
|
|
26
|
+
- ./volumes/postgres:/var/lib/postgresql/data
|
|
27
|
+
- ./volumes/postgres-certs:/var/lib/postgresql/certs:ro
|
|
28
|
+
healthcheck:
|
|
29
|
+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-phlo}"]
|
|
30
|
+
interval: 10s
|
|
31
|
+
timeout: 5s
|
|
32
|
+
retries: 10
|
|
33
|
+
|
|
34
|
+
env_vars:
|
|
35
|
+
POSTGRES_USER:
|
|
36
|
+
default: phlo
|
|
37
|
+
description: PostgreSQL username
|
|
38
|
+
POSTGRES_PASSWORD:
|
|
39
|
+
default: phlo
|
|
40
|
+
description: PostgreSQL password
|
|
41
|
+
secret: true
|
|
42
|
+
POSTGRES_DB:
|
|
43
|
+
default: phlo
|
|
44
|
+
description: PostgreSQL database name
|
|
45
|
+
POSTGRES_PORT:
|
|
46
|
+
default: 5432
|
|
47
|
+
description: PostgreSQL host port
|
|
48
|
+
# SSL/TLS
|
|
49
|
+
POSTGRES_SSL_MODE:
|
|
50
|
+
default: "prefer"
|
|
51
|
+
description: "SSL mode: disable, allow, prefer, require, verify-ca, verify-full"
|
|
52
|
+
POSTGRES_SSL_CERT_FILE:
|
|
53
|
+
default: ""
|
|
54
|
+
description: "Path to SSL certificate file"
|
|
55
|
+
POSTGRES_SSL_KEY_FILE:
|
|
56
|
+
default: ""
|
|
57
|
+
description: "Path to SSL private key file"
|
|
58
|
+
POSTGRES_SSL_CA_FILE:
|
|
59
|
+
default: ""
|
|
60
|
+
description: "Path to SSL CA certificate file"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Postgres settings."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from functools import lru_cache
|
|
6
|
+
from urllib.parse import quote_plus
|
|
7
|
+
|
|
8
|
+
from pydantic import Field
|
|
9
|
+
|
|
10
|
+
from phlo.config.base import BaseConfig
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PostgresSettings(BaseConfig):
|
|
14
|
+
"""PostgreSQL database connection and schema configuration."""
|
|
15
|
+
|
|
16
|
+
postgres_host: str = Field(default="postgres", description="PostgreSQL host")
|
|
17
|
+
postgres_port: int = Field(default=10000, description="PostgreSQL port")
|
|
18
|
+
postgres_user: str = Field(default="lake", description="PostgreSQL username")
|
|
19
|
+
postgres_password: str = Field(default="phlo", description="PostgreSQL password")
|
|
20
|
+
postgres_db: str = Field(default="lakehouse", description="PostgreSQL database name")
|
|
21
|
+
postgres_mart_schema: str = Field(
|
|
22
|
+
default="marts", description="Schema for published mart tables"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def get_postgres_connection_string(self, include_db: bool = True) -> str:
|
|
26
|
+
db_part = f"/{self.postgres_db}" if include_db else ""
|
|
27
|
+
user = quote_plus(self.postgres_user)
|
|
28
|
+
password = quote_plus(self.postgres_password)
|
|
29
|
+
return f"postgresql://{user}:{password}@{self.postgres_host}:{self.postgres_port}{db_part}"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@lru_cache(maxsize=1)
|
|
33
|
+
def get_settings() -> PostgresSettings:
|
|
34
|
+
return PostgresSettings()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: phlo-postgres
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Postgres 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: pyyaml>=6.0.1
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
13
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
14
|
+
|
|
15
|
+
Postgres service plugin for Phlo.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
phlo_postgres/__init__.py,sha256=BeeQUZMLR7x-tWHfuY4hAhr9CJEZXVRO1HfCgdU3aBE,256
|
|
2
|
+
phlo_postgres/exporter_service.yaml,sha256=zVey9kjH0LuAyuk1OJmvWTsAZ_aptlDUa0Z0as4l56I,921
|
|
3
|
+
phlo_postgres/plugin.py,sha256=2CX_qxL1YTiQbQ0Fb6dRD3Ax1_LHPzmM33yR_eDYcvA,1487
|
|
4
|
+
phlo_postgres/service.yaml,sha256=2TXkVjHDEasRuD7lKemyYx48lJJM-0H_YkpIKWs0KMg,1699
|
|
5
|
+
phlo_postgres/settings.py,sha256=AEMZykCGAXQ1cwk0a33svaxrTI21iw1Ajo6-ZE5Kkac,1275
|
|
6
|
+
phlo_postgres-0.1.0.dist-info/METADATA,sha256=Znh-Zf5MYXWszvavM1ldqSFylmZgDaFy900NnTJeo08,410
|
|
7
|
+
phlo_postgres-0.1.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
8
|
+
phlo_postgres-0.1.0.dist-info/entry_points.txt,sha256=OEUFQlRmhOyhHftv5e1hE2HXNJmyp6Vx3GkmhQVAYMA,149
|
|
9
|
+
phlo_postgres-0.1.0.dist-info/top_level.txt,sha256=GX2lGJKXnVVuLJpMoWstq2qFmsYtw0xHzzfE0qOf1jw,14
|
|
10
|
+
phlo_postgres-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
phlo_postgres
|