简介:
Metabase是什么?
在传统企业的数据可视化业务中,通常需要从需求到审批,再到安排开发人员和排期,还要开发人员撰写代码最后再做导出。流程繁琐,参与的人员也多,往往需要几天甚至几周的时间!
使用 Metabase 可以大大节省成本,简单易上手,Metabase 把数据分析常用的查询通过一个个易于操作的界面呈现,非常适合不懂SQL的业务人员使用,只需要点几下鼠标,就可以快速得出一个直观的可视化结果。
Metabase 具有如下特性:
- 支持的数据源:Postgres、MySQL、Druid、SQL Server、ClickHouse、MongoDB、BigQuery、Oracle、Vertica、Presto、Snowflake、Spark等等;
- 人人可用的数据可视化工具,你不需要懂SQL;
- 提供了丰富的仪表盘界面,真正颜值在线的工具,支持数据自动刷新;
- 支持自定义SQL查询,适合懂SQL的人使用;
- 强大的数据透视功能,可以根据数据自动生成仪表板;
- 可以进行多表数据的关联分析,并且无需手写SQ
Metabase快速入门
可快速试用Metabase
开源神器 Metabase,解决数据库的数据可视化难题! - 知乎 (zhihu.com)
Meta提供了开放的API,基本上Metabase页面上能够实现的功能,都可以使用API调通
https://www.metabase.com/docs/latest/api/card
https://www.metabase.com/learn/administration/metabase-api
https://github.com/orgs/tapdata/projects/2?pane=item\&itemId=17413811
API使用:
如图所示,Metabase 生成可视化card功能,虽然只能显示当前结果,但是可以用API获取详细数据,每日通过Tapdata同步到某个目标数据库中。可记录周期结果。
以下是调用Card模块接口示例:
postMan文件:
{
"info": {
"_postman_id": "8240e0b3-2fa6-4d00-8933-cccf994125e8",
"name": "api",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
"_exporter_id": "16923698"
},
"item": [
{
"name": "TAP_GET_TOKEN session api",
"protocolProfileBehavior": {
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"username\": \"{{username}}\", \r\n \"password\": \"{{password}}\"\r\n\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": "http://9b2e67c1ed28.c.methodot.com/api/session"
},
"response": []
},
{
"name": "TAP_TABLE[allCard](PAGE_NONE)allCard",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "X-Metabase-Session",
"value": "{{sessionToken}}",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": "{{matebaseDomainName}}/api/card"
},
"response": []
},
{
"name": "TAP_TABLE[queryExportFormat](PAGE_NONE:data)queryExportFormat",
"request": {
"method": "POST",
"header": [
{
"key": "X-Metabase-Session",
"value": "{{sessionToken}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "{{matebaseDomainName}}/api/card/:card-id/query/:export-format",
"host": [
"{{matebaseDomainName}}"
],
"path": [
"api",
"card",
":card-id",
"query",
":export-format"
],
"variable": [
{
"key": "card-id",
"value": "{{card-id}}"
},
{
"key": "export-format",
"value": "json"
}
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "username",
"value": "skeet@tapdata.io",
"type": "string"
},
{
"key": "password",
"value": "-M90q-CrTJX04U",
"type": "string"
},
{
"key": "matebaseDomainName",
"value": "http://36.134.131.197:12345",
"type": "string"
},
{
"key": "sessionToken",
"value": "5f325571-e1c3-4eeb-b07f-7c269aedb089",
"type": "string"
},
{
"key": "card-id",
"value": "",
"type": "string"
}
]
}
调用API必备参数:username password
- 使用username password获得sessionToken
- 通过第一步获得的sessionToken
- 通过2步得到所有Card的id、name,使用id获得某个Card的详细信息,其中,返回的结果,可选择是json、api、csv等。