Skip to content

Commit 5aed4e1

Browse files
drstrangelookerLuka Fontanilla
andauthored
feat(tools/looker): add support for pulse, vacuum and analyze audit and performance functions on a Looker instance (googleapis#1581)
This pull request adds 3 new tools, looker-health-pulse, looker-health-vacuum, and looker-health-analyze, as capabilities to the Looker MCP Toolbox. These tools are designed to provide health checks and auditing analytical insights for a Looker instance (they come from the popular [Looker CLI tool Henry](https://github.com/looker-open-source/henry)). **looker-health-pulse** This tool performs various health checks on a Looker instance. It can be used to: - Check database connection status. - Identify dashboards with slow-running or erroring queries. - List slow explores and failed schedules. - Find enabled legacy features. **looker-health-analyze** This tool performs analytical tasks on Looker projects, models, and explores. It can be used to: - Analyze projects to check Git status and validation. - Analyze models to count explores and identify unused ones. - Analyze explores to find unused joins and fields. *Unused is defined as not being queried in the last 90 days.* **looker-health-vacuum** This tool finds unnused explores, joins, and fields based on user defined search conditions (namely, timeframe and min query #): - Identify unnused explores for specific or all models - Identify unnused fields or joins for specific explores or all explores within a model This update targets Looker administrators, as it provides new capabilities to monitor the health and efficiency of their Looker instances and connect those capabilities to MCP Clients. 🛠️ Fixes googleapis#1415 --------- Co-authored-by: Luka Fontanilla <maluka@google.com>
1 parent 3be9b7b commit 5aed4e1

File tree

13 files changed

+2205
-1
lines changed

13 files changed

+2205
-1
lines changed

cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ import (
106106
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookergetmeasures"
107107
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookergetmodels"
108108
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookergetparameters"
109+
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookerhealthanalyze"
110+
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookerhealthpulse"
111+
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookerhealthvacuum"
109112
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookermakedashboard"
110113
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookermakelook"
111114
_ "github.com/googleapis/genai-toolbox/internal/tools/looker/lookerquery"

cmd/root_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ func TestPrebuiltTools(t *testing.T) {
14891489
wantToolset: server.ToolsetConfigs{
14901490
"looker_tools": tools.ToolsetConfig{
14911491
Name: "looker_tools",
1492-
ToolNames: []string{"get_models", "get_explores", "get_dimensions", "get_measures", "get_filters", "get_parameters", "query", "query_sql", "query_url", "get_looks", "run_look", "make_look", "get_dashboards", "make_dashboard", "add_dashboard_element"},
1492+
ToolNames: []string{"get_models", "get_explores", "get_dimensions", "get_measures", "get_filters", "get_parameters", "query", "query_sql", "query_url", "get_looks", "run_look", "make_look", "get_dashboards", "make_dashboard", "add_dashboard_element", "health_pulse", "health_analyze", "health_vacuum"},
14931493
},
14941494
},
14951495
},
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: "looker-health-analyze"
3+
type: docs
4+
weight: 1
5+
description: >
6+
"looker-health-analyze" provides a set of analytical commands for a Looker instance, allowing users to analyze projects, models, and explores.
7+
aliases:
8+
- /resources/tools/looker-health-analyze
9+
---
10+
11+
## About
12+
13+
The `looker-health-analyze` tool performs various analysis tasks on a Looker instance. The `action` parameter selects the type of analysis to perform:
14+
15+
- `projects`: Analyzes all projects or a specified project, reporting on the number of models and view files, as well as Git connection and validation status.
16+
- `models`: Analyzes all models or a specified model, providing a count of explores, unused explores, and total query counts.
17+
- `explores`: Analyzes all explores or a specified explore, reporting on the number of joins, unused joins, fields, unused fields, and query counts. Being classified as **Unused** is determined by whether a field has been used as a field or filter within the past 90 days in production.
18+
19+
## Parameters
20+
21+
| **field** | **type** | **required** | **description** |
22+
| :--- | :--- | :--- | :--- |
23+
| kind | string | true | Must be "looker-health-analyze" |
24+
| source | string | true | Looker source name |
25+
| action | string | true | The analysis to perform: `projects`, `models`, or `explores`. |
26+
| project | string | false | The name of the Looker project to analyze. |
27+
| model | string | false | The name of the Looker model to analyze. Required for `explores` actions. |
28+
| explore | string | false | The name of the Looker explore to analyze. Required for the `explores` action. |
29+
| timeframe | int | false | The timeframe in days to analyze. Defaults to 90. |
30+
| min_queries | int | false | The minimum number of queries for a model or explore to be considered used. Defaults to 1. |
31+
32+
## Example
33+
34+
Analyze all models in `thelook` project.
35+
36+
```yaml
37+
tools:
38+
analyze-tool:
39+
kind: looker-health-analyze
40+
source: looker-source
41+
description: |
42+
Analyzes Looker projects, models, and explores.
43+
Specify the `action` parameter to select the type of analysis.
44+
parameters:
45+
action: models
46+
project: "thelook"
47+
48+
Analyze all the explores in the `ecomm` model of `thelook` project. Specifically look at usage within the past 20 days. Usage minimum should be at least 10 queries.
49+
50+
```yaml
51+
tools:
52+
analyze-tool:
53+
kind: looker-health-analyze
54+
source: looker-source
55+
description: |
56+
Analyzes Looker projects, models, and explores.
57+
Specify the `action` parameter to select the type of analysis.
58+
parameters:
59+
action: explores
60+
project: "thelook"
61+
model: "ecomm"
62+
timeframe: 20
63+
min_queries: 10
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "looker-health-pulse"
3+
type: docs
4+
weight: 1
5+
description: >
6+
"looker-health-pulse" performs health checks on a Looker instance, with multiple actions available (e.g., checking database connections, dashboard performance, etc).
7+
aliases:
8+
- /resources/tools/looker-health-pulse
9+
---
10+
11+
## About
12+
13+
The `looker-health-pulse` tool performs health checks on a Looker instance. The `action` parameter selects the type of check to perform:
14+
15+
- `check_db_connections`: Checks all database connections, runs supported tests, and reports query counts.
16+
- `check_dashboard_performance`: Finds dashboards with slow running queries in the last 7 days.
17+
- `check_dashboard_errors`: Lists dashboards with erroring queries in the last 7 days.
18+
- `check_explore_performance`: Lists the slowest explores in the last 7 days and reports average query runtime.
19+
- `check_schedule_failures`: Lists schedules that have failed in the last 7 days.
20+
- `check_legacy_features`: Lists enabled legacy features. (*To note, this function is not available in Looker Core. You will get an error running this command with a Core instance configured.*)
21+
22+
## Parameters
23+
24+
| **field** | **type** | **required** | **description** |
25+
|---------------|:--------:|:------------:|---------------------------------------------|
26+
| kind | string | true | Must be "looker-health-pulse" |
27+
| source | string | true | Looker source name |
28+
| action | string | true | The health check to perform |
29+
30+
## Example
31+
32+
```yaml
33+
tools:
34+
pulse:
35+
kind: looker-health-pulse
36+
source: looker-source
37+
description: |
38+
Pulse Tool
39+
40+
Performs health checks on Looker instance.
41+
Specify the `action` parameter to select the check.
42+
parameters:
43+
action: check_dashboard_performance
44+
```
45+
46+
## Reference
47+
48+
| **action** | **description** |
49+
|---------------------------|--------------------------------------------------------------------------------|
50+
| check_db_connections | Checks all database connections and reports query counts and errors |
51+
| check_dashboard_performance | Finds dashboards with slow queries (>30s) in the last 7 days |
52+
| check_dashboard_errors | Lists dashboards with erroring queries in the last 7 days |
53+
| check_explore_performance | Lists slowest explores and average query runtime |
54+
| check_schedule_failures | Lists failed schedules in the last 7 days |
55+
| check_legacy_features | Lists enabled legacy features |
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: "looker-health-vacuum"
3+
type: docs
4+
weight: 1
5+
description: >
6+
"looker-health-vacuum" provides a set of commands to audit and identify unused LookML objects in a Looker instance.
7+
aliases:
8+
- /resources/tools/looker-health-vacuum
9+
---
10+
11+
## About
12+
13+
The `looker-health-vacuum` tool helps you identify unused LookML objects such as models, explores, joins, and fields. The `action` parameter selects the type of vacuum to perform:
14+
15+
- `models`: Identifies unused explores within a model.
16+
- `explores`: Identifies unused joins and fields within an explore.
17+
18+
## Parameters
19+
20+
| **field** | **type** | **required** | **description** |
21+
| :--- | :--- | :--- | :--- |
22+
| kind | string | true | Must be "looker-health-vacuum" |
23+
| source | string | true | Looker source name |
24+
| action | string | true | The vacuum to perform: `models`, or `explores`. |
25+
| project | string | false | The name of the Looker project to vacuum. |
26+
| model | string | false | The name of the Looker model to vacuum. |
27+
| explore | string | false | The name of the Looker explore to vacuum. |
28+
| timeframe | int | false | The timeframe in days to analyze for usage. Defaults to 90. |
29+
| min_queries | int | false | The minimum number of queries for an object to be considered used. Defaults to 1. |
30+
31+
## Example
32+
33+
Identify unnused fields (*in this case, less than 1 query in the last 20 days*) and joins in the `order_items` explore and `thelook` model
34+
35+
```yaml
36+
tools:
37+
vacuum-tool:
38+
kind: looker-health-vacuum
39+
source: looker-source
40+
description: |
41+
Vacuums the Looker instance by identifying unused explores, fields, and joins.
42+
parameters:
43+
action: explores
44+
project: "thelook_core"
45+
model: "thelook"
46+
explore: "order_items"
47+
timeframe: 20
48+
min_queries: 1
49+
```
50+
51+
Identify unnused explores across all models in `thelook_core` project.
52+
53+
```yaml
54+
tools:
55+
vacuum-tool:
56+
kind: looker-health-vacuum
57+
source: looker-source
58+
description: |
59+
Vacuums the Looker instance by identifying unused explores, fields, and joins.
60+
parameters:
61+
action: models
62+
project: "thelook_core"
63+

internal/prebuiltconfigs/tools/looker.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,56 @@ tools:
695695
This tool can be called many times for one dashboard_id
696696
and the resulting tiles will be added in order.
697697
698+
health_pulse:
699+
kind: looker-health-pulse
700+
source: looker-source
701+
description: |
702+
health-pulse Tool
703+
704+
This tool takes the pulse of a Looker instance by taking
705+
one of the following actions:
706+
1. `check_db_connections`,
707+
2. `check_dashboard_performance`,
708+
3. `check_dashboard_errors`,
709+
4. `check_explore_performance`,
710+
5. `check_schedule_failures`, or
711+
6. `check_legacy_features`
712+
713+
health_analyze:
714+
kind: looker-health-analyze
715+
source: looker-source
716+
description: |
717+
health-analyze Tool
718+
719+
This tool calculates the usage of projects, models and explores.
720+
721+
It accepts 6 parameters:
722+
1. `action`: can be "projects", "models", or "explores"
723+
2. `project`: the project to analyze (optional)
724+
3. `model`: the model to analyze (optional)
725+
4. `explore`: the explore to analyze (optional)
726+
5. `timeframe`: the lookback period in days, default is 90
727+
6. `min_queries`: the minimum number of queries to consider a resource as active, default is 1
728+
729+
health_vacuum:
730+
kind: looker-health-vacuum
731+
source: looker-source
732+
description: |
733+
health-vacuum Tool
734+
735+
This tool suggests models or explores that can removed
736+
because they are unused.
737+
738+
It accepts 6 parameters:
739+
1. `action`: can be "models" or "explores"
740+
2. `project`: the project to vacuum (optional)
741+
3. `model`: the model to vacuum (optional)
742+
4. `explore`: the explore to vacuum (optional)
743+
5. `timeframe`: the lookback period in days, default is 90
744+
6. `min_queries`: the minimum number of queries to consider a resource as active, default is 1
745+
746+
The result is a list of objects that are candidates for deletion.
747+
698748
toolsets:
699749
looker_tools:
700750
- get_models
@@ -712,3 +762,6 @@ toolsets:
712762
- get_dashboards
713763
- make_dashboard
714764
- add_dashboard_element
765+
- health_pulse
766+
- health_analyze
767+
- health_vacuum

0 commit comments

Comments
 (0)