一个Looker清理工具
项目描述
Henry:一个Looker清理工具
Henry是一个命令行工具,帮助您确定Looker实例中的模型膨胀并识别模型和探索中未使用的功能。它旨在帮助开发人员从未使用的探索中清理模型,从未使用的连接和字段中清理探索,以及维护一个健康、友好的实例。
目录
状态和支持
Henry在任何方面都未经Looker支持或保证。请勿联系Looker支持解决Henry的问题。问题可以通过https://github.com/looker-open-source/henry/issues记录
安装
Henry需要python3.7+。它发布在PyPI上,可以使用pip安装
$ pip install henry
为了开发设置,请遵循下面的开发设置。
使用
为了显示使用信息,请使用
$ henry --help
适用于许多命令的全局选项
身份验证
Henry使用Looker SDK发出API调用,并需要API3凭证。这些凭证可以通过.ini文件或环境变量提供,如在此处记录所示。默认情况下,该工具在工作目录中查找名为"looker.ini"的文件。如果配置文件的名称不同或位于其他位置,则必须使用--config-file
参数指定。
示例.ini文件
[Looker]
# Base URL for API. Do not include /api/* in the url
base_url=https://self-signed.looker.com:19999
# API 3 client id
client_id=YourClientID
# API 3 client secret
client_secret=YourClientSecret
# Set to false if testing locally against self-signed certs. Otherwise leave True
verify_ssl=True
[Production]
base_url=https://production.looker.com:19999
client_id=YourClientID
client_secret=YourClientSecret
verify_ssl=True
假设以上ini文件内容,可以按照以下方式运行Henry:
$ henry pulse --config-file=looker.ini --section=Looker
由于默认设置,这相当于:
$ henry pulse
使用“生产”部分下的详细信息运行它,可以按照以下方式:
$ henry pulse --section=Production
API超时设置
默认情况下,API调用超时时间为120秒。可以使用--timeout
参数来覆盖。
输出到文件
如果使用--save
标志,则工具会将结果保存到您的当前工作目录。示例用法
$ henry vacuum models --save
将结果保存到当前工作目录中的vacuum_models_{date}_{time}.csv。
Pulse命令
命令henry pulse
运行一系列测试,有助于确定实例的整体健康状况。
分析命令
命令analyze
旨在帮助识别变得臃肿的模型和探索,并使用vacuum
对其进行修剪。
分析项目
命令analyze projects
扫描项目内容,并检查成功所需的基本功能的状态,如git连接状态和验证要求。
+-------------------+---------------+--------------+-------------------------+---------------------+------------------------+
| Project | # Models | # View Files | Git Connection Status | PR Mode | Is Validation Required |
|-------------------+---------------+--------------+-------------------------+---------------------+------------------------|
| marketing | 1 | 13 | OK | links | True |
| admin | 2 | 74 | OK | off | True |
| powered_by_looker | 1 | 14 | OK | links | True |
| salesforce | 1 | 36 | OK | required | False |
| thelook_event | 1 | 17 | OK | required | True |
+-------------------+---------------+--------------+-------------------------+---------------------+------------------------+
分析模型
显示每个模型中的探索数量以及针对该模型查询的数量。
+-------------------+------------------+-----------------+-------------------+-------------------+
| Project | Model | # Explores | # Unused Explores | Query Count |
|-------------------+------------------+-----------------+-------------------+-------------------|
| salesforce | salesforce | 8 | 0 | 39923 |
| thelook_event | thelook | 10 | 0 | 166307 |
| powered_by_looker | powered_by | 5 | 0 | 49122 |
| marketing | thelook_adwords | 3 | 0 | 40869 |
| admin | looker_base | 0 | 0 | 0 |
| admin | looker_on_looker | 10 | 9 | 28 |
+-------------------+------------------+-----------------+-------------------+-------------------+
分析探索
显示探索及其使用情况。如果传递了--min-queries
参数,则使用阈值以下的使用次数的连接和字段将被视为未使用。
+---------+-----------------------------------------+-------------+-------------------+--------------+----------------+---------------+-----------------+---------------+
| Model | Explore | Is Hidden | Has Description | # Joins | # Unused Joins | # Fields | # Unused Fields | Query Count |
|---------+-----------------------------------------+-------------+-------------------+--------------+----------------+---------------+-----------------+---------------|
| thelook | cohorts | True | False | 3 | 0 | 19 | 4 | 333 |
| thelook | data_tool | True | False | 3 | 0 | 111 | 90 | 736 |
| thelook | order_items | False | True | 7 | 0 | 153 | 16 | 126898 |
| thelook | events | False | True | 6 | 0 | 167 | 68 | 19372 |
| thelook | sessions | False | False | 6 | 0 | 167 | 83 | 12205 |
| thelook | affinity | False | False | 2 | 0 | 34 | 13 | 3179 |
| thelook | orders_with_share_of_wallet_application | False | True | 9 | 0 | 161 | 140 | 1586 |
| thelook | journey_mapping | False | False | 11 | 2 | 238 | 228 | 14 |
| thelook | inventory_snapshot | False | False | 3 | 0 | 25 | 15 | 33 |
| thelook | kitten_order_items | True | False | 8 | 0 | 154 | 138 | 39 |
+---------+-----------------------------------------+-------------+-------------------+--------------+----------------+---------------+-----------------+---------------+
真空信息
命令vacuum
根据预定义的准则输出未使用的内容,开发人员可以使用这些内容来清理模型和探索。
真空模型
命令vacuum models
公开模型及其查询数量,时间跨度预设。列出的探索在该时间段内没有达到最低查询次数。因此,可以安全地隐藏它们并在以后删除。
+------------------+---------------------------------------------+-------------------------+
| Model | Explore | Model Query Count |
|------------------+---------------------------------------------+-------------------------|
| salesforce | | 39450 |
| thelook | | 164930 |
| powered_by | | 49453 |
| thelook_adwords | | 38108 |
| looker_on_looker | user_full | 27 |
| | history_full | |
| | content_view | |
| | project_status | |
| | field_usage_full | |
| | dashboard_performance_full | |
| | user_weekly_app_activity_period_over_period | |
| | pdt_state | |
| | user_daily_query_activity | |
+------------------+---------------------------------------------+-------------------------+
真空探索
命令vacuum explores
公开在指定时间段内查询次数低于或等于最小查询次数阈值的连接和字段(默认=0,可以使用--min-queries
参数更改)。默认时间范围是90天,可以使用--timeframe
参数更改。
例如:从上面的分析函数运行上述,我们知道cohorts探索有4个字段在过去的90天内一次都没有被查询过。运行以下真空命令
$ henry vacuum explores --model thelook --explore cohorts
提供了未使用字段的名称
+---------+-----------+----------------+------------------------------+
| Model | Explore | Unused Joins | Unused Fields |
|---------+-----------+----------------+------------------------------|
| thelook | cohorts | users | users.id |
| | | | order_items.id |
| | | | order_items.id |
| | | | order_items.total_sale_price |
+---------+-----------+----------------+------------------------------+
如果连接未使用,这意味着该连接引入的字段在定义的时间框架内没有被使用。因此,作为该连接结果公开的字段不会明确列出为未使用字段。
非常重要的一点是要注意,在某个探索中列为未使用的字段并不意味着要从视图中完全删除,因为它们可能在其他探索(通过扩展)或过滤器中使用。相反,应该隐藏这些字段(如果它们在别处没有被使用),或者使用fields LookML参数从探索中排除它们。
贡献
请参阅CONTRIBUTING文件。欢迎在GitHub上提交错误报告和拉取请求:https://github.com/looker-open-source/henry/issues。
行为准则
预期与Henry项目的代码库、问题跟踪器、聊天室和邮件列表互动的所有人都应遵循行为准则。
版权
版权(c)2018 Joseph Axisa,Looker Data Sciences。有关更多信息,请参阅MIT许可证。
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装软件包的更多信息。
源代码分发
构建分发
henry-temp-fix-1.1.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7adee1a2de8a34681b993015d39b09c71ccf73f664ce442698f4dab02cd0ad6b |
|
MD5 | c6e0349c7dd0a8f954e8e97be598a0c2 |
|
BLAKE2b-256 | 240c01d692bc809b5774943aff4957748cd9f7b3cf48253925c2c1433f7a4372 |
henry_temp_fix-1.1.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0be1171f5cc166c5a6c7df8de4557491dbbed7fc10f4093698cacab3653cd254 |
|
MD5 | dd0ee0224c5af1297573661708be22a5 |
|
BLAKE2b-256 | 473331a2fd4ef9c2c04eeeb85c043f28788937f8be784d1bb6574bd509955ccf |