|
20 | 20 |
|
21 | 21 | classPostgresReportGenerator: |
22 | 22 | def__init__(self,prometheus_url:str="http://sink-prometheus:9090", |
23 | | -postgres_sink_url:str="postgresql://pgwatch:pgwatchadmin@sink-postgres:5432/measurements"): |
| 23 | +postgres_sink_url:str="postgresql://pgwatch@sink-postgres:5432/measurements"): |
24 | 24 | """ |
25 | 25 | Initialize the PostgreSQL report generator. |
26 | 26 |
|
27 | 27 | Args: |
28 | 28 | prometheus_url: URL of the Prometheus instance (default: http://sink-prometheus:9090) |
29 | 29 | postgres_sink_url: Connection string for the Postgres sink database |
30 | | - (default: postgresql://pgwatch:pgwatchadmin@sink-postgres:5432/measurements) |
| 30 | + (default: postgresql://pgwatch@sink-postgres:5432/measurements) |
31 | 31 | """ |
32 | 32 | self.prometheus_url=prometheus_url |
33 | 33 | self.base_url=f"{prometheus_url}/api/v1" |
@@ -78,12 +78,12 @@ def get_index_definitions_from_sink(self) -> Dict[str, str]: |
78 | 78 | withself.pg_conn.cursor(cursor_factory=psycopg2.extras.DictCursor)ascursor: |
79 | 79 | # Query the index_definitions table for the most recent data |
80 | 80 | query=""" |
81 | | -SELECT DISTINCT ON (data->>'indexrelname') |
| 81 | +select distinct on (data->>'indexrelname') |
82 | 82 | data->>'indexrelname' as indexrelname, |
83 | 83 | data->>'index_definition' as index_definition |
84 | | -FROM public.index_definitions |
85 | | -WHERE data ? 'indexrelname'AND data ? 'index_definition' |
86 | | -ORDER BY data->>'indexrelname', timeDESC |
| 84 | +from public.index_definitions |
| 85 | +where data ? 'indexrelname'and data ? 'index_definition' |
| 86 | +order by data->>'indexrelname', timedesc |
87 | 87 | """ |
88 | 88 | cursor.execute(query) |
89 | 89 |
|
|