Skip to content

Commit

Permalink
Remove pg_indexes queries from monitors celery task (#3164)
Browse files Browse the repository at this point in the history
* Remove indexes query from monitors

* lint
  • Loading branch information
dmanjunath authored May 26, 2022
1 parent 8f412bf commit 424a7c6
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 58 deletions.
36 changes: 0 additions & 36 deletions discovery-provider/src/monitors/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,6 @@ def get_database_connection_info(**kwargs):
return json.dumps(connection_info)


def get_database_index_count(**kwargs):
"""
Gets number of indexes in the database
Kwargs:
db: global database instance
redis: global redis instance
"""
db = kwargs["db"]
with db.scoped_session() as session:
q = sqlalchemy.text(
"SELECT COUNT(*) FROM pg_indexes WHERE schemaname = 'public'"
)
res = session.execute(q).fetchone()[0]
return res


def get_database_index_info(**kwargs):
"""
Gets full database index information (tablename, indexname, indexdef)
Kwargs:
db: global database instance
redis: global redis instance
"""
db = kwargs["db"]
with db.scoped_session() as session:
q = sqlalchemy.text(
"SELECT tablename, indexname, indexdef FROM pg_indexes WHERE schemaname = 'public'"
+ "ORDER BY tablename, indexname"
)
result = session.execute(q).fetchall()
connection_info = [dict(row) for row in result]
return json.dumps(connection_info)


def get_table_size_info(**kwargs):
"""
Gets table information (number of rows, data size).
Expand Down
2 changes: 0 additions & 2 deletions discovery-provider/src/monitors/monitor_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
database_size = "database_size"
database_connections = "database_connections"
database_connection_info = "database_connection_info"
database_index_count = "database_index_count"
database_index_info = "database_index_info"
table_size_info = "table_size_info"
frequent_queries = "frequent_queries"
slow_queries = "slow_queries"
Expand Down
18 changes: 0 additions & 18 deletions discovery-provider/src/monitors/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from src.monitors.database import (
get_database_connection_info,
get_database_connections,
get_database_index_count,
get_database_index_info,
get_database_liveness,
get_database_size,
get_frequent_queries,
Expand Down Expand Up @@ -65,20 +63,6 @@
monitor_names.type: "json",
}

DATABASE_INDEX_COUNT = {
monitor_names.name: monitor_names.database_index_count,
monitor_names.func: get_database_index_count,
monitor_names.ttl: 60 * 60 * 6, # six hours
monitor_names.type: "int",
}

DATABASE_INDEX_INFO = {
monitor_names.name: monitor_names.database_index_info,
monitor_names.func: get_database_index_info,
monitor_names.ttl: 60 * 60 * 6, # six hours
monitor_names.type: "json",
}

TABLE_SIZE_INFO = {
monitor_names.name: monitor_names.table_size_info,
monitor_names.func: get_table_size_info,
Expand Down Expand Up @@ -166,8 +150,6 @@
monitor_names.database_size: DATABASE_SIZE,
monitor_names.database_connections: DATABASE_CONNECTIONS,
monitor_names.database_connection_info: DATABASE_CONNECTION_INFO,
monitor_names.database_index_count: DATABASE_INDEX_COUNT,
monitor_names.database_index_info: DATABASE_INDEX_INFO,
monitor_names.table_size_info: TABLE_SIZE_INFO,
monitor_names.frequent_queries: FREQUENT_QUERIES,
monitor_names.slow_queries: SLOW_QUERIES,
Expand Down
2 changes: 0 additions & 2 deletions discovery-provider/src/queries/get_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ def _get_db_conn_state():
[
MONITORS[monitor_names.database_connections],
MONITORS[monitor_names.database_connection_info],
MONITORS[monitor_names.database_index_count],
MONITORS[monitor_names.database_index_info],
]
)

Expand Down

0 comments on commit 424a7c6

Please sign in to comment.