保养¶
The analytics API provides endpoints for investigation of query performance issues. It is implemented as part of all analytics endpoints:¶
analytics/explain
analytics/event/explain
analytics/enrollment/explain
例
GET /api/analytics/explain?displayProperty=NAME
&dimension=dx:Uvn6LCg7dVU;sB79w2hiLp8,ou:USER_ORGUNIT
&filter=pe:THIS_YEAR&includeNumDen=false&skipMeta=false
&skipData=true&includeMetadataDetails=true
响应将显示 PostgreSQL 计划项目为所提供语句生成的执行计划。
| eventCreatedPeriod | 用户设置 { #webapi_user_settings } | Parameter name |
|---|---|---|
| Analytics explain { #webapi_analytics_explain } | 假 | Event analytics explain { #webapi_event_analytics_explain } |
| /api/analytics/event/aggregate/{program}/explain |
/api/analytics/event/query/{program}/explain | 假 | /api/analytics/enrollment/query/{program}/explain |
| Outliers analytics explain { #webapi_analytics_outlier_detection_explain } | 假 | 保养 | | Resource and analytics tables { #webapi_generating_resource_analytics_tables } | 假 | 资源表由 DHIS2 应用项目内部使用 各种分析功能。这些表对用户也很有价值 编写高级 SQL 报告。它们可以通过 POST 或 PUT 生成 请求到以下 URL: | | / api / 33 / resourceTables | 假 | / api / 33 / resourceTables / analytics | | Table: Analytics tables optional query parameters | 查询参数 | 选项 |
描述
skipResourceTables
false | true
Skip generation of resource tables
skipAggregate
false | true¶
Skip generation of aggregate data and completeness data
skipEvents
false | true
Skip generation of event data
skipEnrollment
false | true
Skip generation of enrollment data
skipOrgUnitOwnership
false | true
Skip generation of organization unit ownership data
lastYears
整数
Number of last years of data to include
Note
lastYears=0 means latest or continuous analytics, as defined in Continuous analytics table.
“数据质量”和“数据监控”可通过监控运行 任务,由以下端点触发:
/ api / 33 / resourceTables / monitoring
此任务将分析您的验证规则,查找任何违规并 将它们保存为验证结果。
这些请求将立即返回并启动服务器端 过程。
保养 { #webapi_maintenance }
要执行维护,您可以与 maintenance 资源进行交互。您应该使用 POST 或 PUT 作为请求方法。可以使用以下方法。
清除分析表将删除所有分析表。
开机自检/ api / maintenance / analyticsTablesClear
分析表分析将收集有关数据库中分析表内容的统计信息。
开机自检/ api / maintenance / analyticsTablesAnalyze
清除过期邀请将删除所有用户帐户邀请 已过期。
开机自检/ api / maintenance / expiredInvitationsClear
期间修剪将删除未链接到任何数据的期间 值。
开机自检/ api / maintenance / periodPruning
零数据值删除将删除链接到数据的零数据值 零数据被定义为不重要的元素:
开机自检/ api / maintenance / zeroDataValueRemoval
软删除的数据值删除将永久删除软删除的数据值。
开机自检/ api / maintenance / softDeletedDataValueRemoval
软删除的项目阶段实例删除将永久删除软删除的事件。
开机自检/ api / maintenance / softDeletedProgramStageInstanceRemoval
软删除项目实例的删除将永久删除软删除的注册。
开机自检/ api / maintenance / softDeletedProgramInstanceRemoval
软删除的跟踪实体实例的删除将永久删除软删除的跟踪实体实例。
开机自检/ api / maintenance / softDeletedTrackedEntityInstanceRemoval
删除SQL视图将删除数据库中的所有SQL视图。请注意,它不会删除DHIS2 SQL视图实体。
开机自检/ api / maintenance / sqlViewsDrop
创建SQL视图将重新创建数据库中的所有SQL视图。
开机自检/ api / maintenance / sqlViewsCreate¶
类别选项组合更新将删除过时并为所有类别组合生成缺少的类别选项组合。
开机自检/ api / maintenance / categoryOptionComboUpdate¶
也可以使用以下端点为单个类别组合更新类别选项组合。
开机自检/ api / maintenance / categoryOptionComboUpdate / categoryCombo / <category-combo-uid>
缓存清除将清除应用项目Hibernate缓存和分析分区缓存。
开机自检/ api / maintenance / cacheClear
组织单位路径更新将重新生成组织单位路径属性。这可能是有用的,例如如果您使用SQL导入组织单位。
-
开机自检/ api / maintenance / ouPathsUpdate
-
数据修剪将删除完整的数据集注册,数据批准,数据价值审核和数据价值,在这种情况下是组织单位。 开机自检/ api / maintenance / dataPruning / organisationUnits /
-
数据元素的数据修剪,这将删除数据值审核和数据值。
POST PUT /api/maintenance/dataPruning/dataElements/¶
元数据验证将应用所有元数据验证规则,并返回操作结果。
开机自检/ api / metadataValidation
应用项目重新加载将通过从文件系统读取来刷新已安装应用项目的DHIS2托管缓存。
开机自检/ api / appReload
通过对api / maintenance资源的POST请求以批处理方式支持维护操作,在api / maintenance资源中,该操作作为查询参数提供:
开机自检/ api / maintenance?analyticsTablesClear = true&expiredInvitationsClear = true
&periodPruning = true&zeroDataValueRemoval = true&sqlViewsDrop = true&sqlViewsCreate = true
&categoryOptionComboUpdate = true&cacheClear = true&ouPathsUpdate = true
系统信息 { #webapi_system_resource }
系统资源为您提供方便的信息和¶
职能。系统资源可以在 /api/system 中找到。
产生识别码 { #webapi_system_resource_generate_identifiers }
要生成有效的随机 DHIS2 标识符,您可以执行 GET 请求 此资源:
/ api / 33 / system / id?limit = 3
limit 查询参数是可选的,表示有多少 您希望与响应一起返回的标识符。默认为 返回一个标识符。响应将包含一个带有 数组命名代码,类似于:
| json { "codes": [ "Y0moqFplrX4", "WI0VHXuWQuV", "BRJNBBpu4ki" ] } | Parameter name | 长11个字符。 | |---|---|---| | 200 | 仅字母数字字符,即。字母或数字字符 | (A-Za-z0-9)。 | | 302 | 以字母字符(A-Za-z)开头。 | 查看系统信息 { #webapi_system_resource_view_system_information } | | 401 | 要获取有关当前系统的信息,您可以执行 GET 请求 这个网址: | / api / 33 / system / info |
支持 JSON 和 JSONP 响应格式。系统信息响应¶
目前包括以下属性。
{
"contextPath": "http://yourdomain.com",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/29.0.1547.62",
"calendar": "iso8601",
"dateFormat": "yyyy-mm-dd",
"serverDate": "2021-01-05T09:16:03.548",
"serverTimeZoneId": "Etc/UTC",
"serverTimeZoneDisplayName": "Coordinated Universal Time",
"version": "2.13-SNAPSHOT",
"revision": "11852",
"buildTime": "2013-09-01T21:36:21.000+0000",
"serverDate": "2013-09-02T12:35:54.311+0000",
"environmentVariable": "DHIS2_HOME",
"javaVersion": "1.7.0_06",
"javaVendor": "Oracle Corporation",
"javaIoTmpDir": "/tmp",
"javaOpts": "-Xms600m -Xmx1500m -XX:PermSize=400m -XX:MaxPermSize=500m",
"osName": "Linux",
"osArchitecture": "amd64",
"osVersion": "3.2.0-52-generic",
"externalDirectory": "/home/dhis/config/dhis2",
"databaseInfo": {
"type": "PostgreSQL",
"name": "dhis2",
"user": "dhis",
"spatialSupport": false
},
"memoryInfo": "Mem Total in JVM: 848 Free in JVM: 581 Max Limit: 1333",
"cpuCores": 8
}
注意
如果请求此资源的用户不具有完全权限,则仅包括不被视为敏感的属性。
仅获取有关系统上下文的信息,即contextPath 和 userAgent,您可以向以下 URL 发出 GET 请求。 JSON 和 支持 JSONP 响应格式:
| authSubset | Parameter name |
|---|---|
| 检查某些用户凭据(用户名和密码组合) | |
| 是正确的,您可以使用以下资源向以下资源发出 GET 请求 | |
| 基本认证: | / api / 33 / system / ping |
| 您可以通过检查 *HTTP 来检测身份验证的结果 | |
| 响应头的状态码*。可能状态的含义 | |
| 代码如下。请注意,这适用于 Web API 请求 | |
| 一般的。 | Table: HTTP Status codes |
| HTTP Status code | 描述 |
| Outcome | OK |
| Authentication was successful | Found |
| No credentials were supplied with the request - no authentication took place | Unauthorized |
| The username and password combination was incorrect - authentication failed | 查看异步任务状态 { #webapi_system_resource_view_async_task_status } |
| Tasks which often take a long time to complete can be performed | |
| asynchronously. After initiating an async task you can poll the status | |
through the system/tasks resource by supplying the task category and | |
| the task identifier of interest. | 轮询任务状态时,您需要进行身份验证 |
| 启动任务的用户。以下任务类别是 | |
| 支持的: | |
| Table: Task categories | 识别码 |
描述
监控任务¶
Generation of the analytics tables.
RESOURCE_TABLE
Generation of the resource tables.
MONITORING
Processing of data surveillance/monitoring validation rules.
DATAVALUE_IMPORT
监视类别的所有任务¶
EVENT_IMPORT
Import of events.
ENROLLMENT_IMPORT
Import of enrollments.
监控所有任务¶
Import of tracked entity instances.
METADATA_IMPORT
Import of metadata.
DATA_INTEGRITY
查看异步任务摘要¶
每个异步任务都会自动分配一个标识符,该标识符可以 用于监视任务的状态。这个任务标识符是 当您通过各种方式启动异步任务时由 API 返回 启用异步的端点。
Monitoring a task
您可以通过对系统任务的 GET 请求轮询任务状态 像这样的资源:
/ api / 33 / system / tasks / {task-category-id} / {task-id}
一个示例请求可能看起来像这样:
Import of metadata.
响应将提供有关状态的信息,例如 通知级别、类别、时间和状态。 *已完成的*属性 指示该过程是否被认为是完整的。
[{
"uid": "hpiaeMy7wFX",
"level": "INFO",
"category": "DATAVALUE_IMPORT",
"time": "2015-09-02T07:43:14.595+0000",
"message": "Import done",
"completed": true
}]
Monitoring all tasks for a category
您可以通过 GET 请求轮询特定类别的所有任务¶
系统任务资源:
/ api / 33 / system / tasks / {task-category-id}
轮询数据值导入任务状态的示例请求 看起来像这样:
/ api / 33 / system / tasks / DATAVALUE_IMPORT
Monitor all tasks
集群信息{ #cluster-info }¶
/ api / 33 / system / tasks
响应将类似于以下内容:
[{
"EVENT_IMPORT": {},
"DATA_STATISTICS": {},
"RESOURCE_TABLE": {},
"FILE_RESOURCE_CLEANUP": {},
"METADATA_IMPORT": {},
"CREDENTIALS_EXPIRY_ALERT": {},
"SMS_SEND": {},
"MOCK": {},
"ANALYTICSTABLE_UPDATE": {},
"COMPLETE_DATA_SET_REGISTRATION_IMPORT": {},
"DATAVALUE_IMPORT": {},
"DATA_SET_NOTIFICATION": {},
"DATA_INTEGRITY": {
"OB1qGRlCzap": [{
"uid": "LdHQK0PXZyF",
"level": "INFO",
"category": "DATA_INTEGRITY",
"time": "2018-03-26T15:02:32.171",
"message": "Data integrity checks completed in 38.31 seconds.",
"completed": true
}]
},
"PUSH_ANALYSIS": {},
"MONITORING": {},
"VALIDATION_RESULTS_NOTIFICATION": {},
"REMOVE_EXPIRED_RESERVED_VALUES": {},
"DATA_SYNC": {},
"SEND_SCHEDULED_MESSAGE": {},
"DATAVALUE_IMPORT_INTERNAL": {},
"PROGRAM_NOTIFICATIONS": {},
"META_DATA_SYNC": {},
"ANALYTICS_TABLE": {},
"PREDICTOR": {}
}]
View asynchronous task summaries
任务摘要资源允许您检索任务摘要¶
异步任务调用。您需要指定类别和 可选的任务标识符。任务标识符可以是 从发起请求的 API 请求的响应中检索 异步任务。
要检索特定任务的摘要,您可以发出以下请求:
/ api / 33 / system / taskSummaries / {task-category-id} / {task-id}
一个示例请求可能看起来像这样:
| 响应示例: | Parameter name | 您还可以通过发布到 通知资源如下所述。 F_SEND_EMAIL 或 ALL 权限必须在系统中才能使用这个 api。主题 参数是可选的。 “DHIS 2”字符串将作为默认主题发送 如果 url 中没有提供。应该对 URL 进行编码才能使用它 应用项目接口。 | |---|---|---| | json { "source": "rspjJHg4WY1", "targets": [ "HT0w9YLMLyn", "rEpnzuNpRKM" ], "primaryTarget": "HT0w9YLMLyn", "deleteSource": true } | / api / 33 / system / taskSummaries / {task-category-id} | 具有以下要求: | | 最小最大数据元素 | / api / 33 / system / flags | 具有以下要求: | | 预测变量 | Cluster info | 具有以下要求: | | 整数 | A sample JSON response looks like this: | Enrollments | | 最小-最大数据元素 { #webapi_min_max_data_elements } | min-max 数据元素资源允许您设置最小值和最大值 数据元素的值范围。它是独一无二的 组织单位、数据元素和类别选项组合。 | Enrollments | | POST /api/minMaxDataElements/upsert | 项目 | userDataStore 由用户、命名空间、键和关联的 值。用户、命名空间和密钥的组合是唯一的。 |
数据类型
source
Organisation unit identifier
串
dataElement
Data element identifier
串¶
optionCombo
Data element category option combo identifier
串
generated
Minimum value
整数¶
最大
Maximum value
整数
generated
Indicates whether this object is generated by the system (and not set manually).¶
Boolean
您可以从以下位置检索所有最小-最大数据元素的列表 资源:
GET /api/minMaxDataElements.json
您可以像这样过滤响应:
GET /api/minMaxDataElements.json?filter=dataElement.id:eq:UOlfIjgN8X6
GET /api/minMaxDataElements.json?filter=dataElement.id:in:[UOlfIjgN8X6,xc8gmAKfO95]
min-max 数据元素的过滤器参数支持两种运算符: eq 和 in。您还可以使用 fields 查询参数。
GET /api/minMaxDataElements.json?fields=:all,dataElement[id,name]
Add/update single min-max data element { #webapi_add_update_min_max_data_element }
| 要添加新的最小-最大数据元素,请使用POST请求执行以下操作: | Parameter name |
|---|---|
| 最小最大数据元素 | ```json |
| { | |
| "min": 1, | |
| "generated": false, | |
| "max": 100, | |
| "dataElement": { | |
| "id": "UOlfIjgN8X6" | |
| }, | |
| "source": { | |
| "id": "DiszpKrYNg8" | |
| }, | |
| "optionCombo": { | |
| "id": "psbwp3CQEhs" | |
| } | |
| } | |
| ``` | |
{"type":"ABSOLUTE","startDate":"2020-03-01","endDate":"2022-12-30"} | Delete single min-max data element { #webapi_delete_min_max_data_element } |
| 预测变量 | 删除/api/minMaxDataElements.json |
| JSON内容的格式与上述类似: | ```json |
| { | |
| "min": 1, | |
| "generated": false, | |
| "max": 100, | |
| "dataElement": { | |
| "id": "UOlfIjgN8X6" | |
| }, | |
| "source": { | |
| "id": "DiszpKrYNg8" | |
| }, | |
| "optionCombo": { | |
| "id": "psbwp3CQEhs" | |
| } | |
| } | |
| ``` | |
| Add/update multiple min-max data elements { #webapi_add_update_multiple_min_max_data_elements } | To add or update multiple min-max data elements, you can use a POST request to the following resource: |
| POST /api/minMaxDataElements/upsert | The JSON content format for multiple min-max data elements looks like this: |
[
{
"dataSet": "BfMAe6Itzgt",
"values": [
{
"dataElement": "s46m5MS0hxu",
"orgUnit": "Qc9lf4VM9bD",
"optionCombo": "Prlt0C1RF0s",
"minValue": 27,
"maxValue": 564
},
{
"dataElement": "s46m5MS0hxu",
"orgUnit": "Qc9lf4VM9bD",
"optionCombo": "V6L425pT3A0",
"minValue": 0,
"maxValue": 100
}
]
Note that the dataSet property is required in the request body when using JSON. Each min-max value should contain UID references to dataElement, orgUnit, optionCombo. The minValue and maxValue properties represent the minimum and maximum values for the data element, respectively and will be parsed as integers.
You can also specify the generated property if you want to indicate whether the min-max data element is generated by the system or set manually. If not specified, it defaults to true.¶
Gzipped JSON payloads are also supported for this endpoint, which can be useful for large datasets. The server will automatically decompress the gzipped content. If you send a gzipped payload, make sure to set the Content-Encoding header to gzip and include the Content-Type header with the value application/json. The payload itself should be part of the request body.
CSV payloads are also supported for this endpoint. The CSV file should be delimited with commas. You should set the Content-Type header to text/csv and the Accept header to application/json. You will also need to specify the dataSet query parameter in the request URL. The CSV payload should contain the following columns:
Column Name
描述¶
dataElement
The UID of the data element
orgUnit
The UID of the organisation unit
optionCombo
The UID of the category option combo
minValue¶
The minimum value for the data element
maxValue
The maximum value for the data element
generated
(optional) Indicates whether the min-max data element is generated by the system or set manually. Defaults to true if not specified.
An example CSV payload might look like this:
dataElement,orgUnit,optionCombo,minValue,maxValue,generated
s46m5MS0hxu,Qc9lf4VM9bD,Prlt0C1RF0s,27,564,false
s46m5MS0hxu,Qc9lf4VM9bD,V6L425pT3A0,0,100,true
Delete multiple min-max data elements { #webapi_delete_multiple_min_max_data_elements }
To delete multiple min-max data elements, you can use a DELETE request to the following resource:
DELETE /api/minMaxDataElements/delete
The JSON content for the request body should be in the same format as for adding or updating multiple min-max data elements, but you only need to specify the dataElement, orgUnit, and optionCombo properties for each min-max data element you want to delete. The minValue, maxValue, and generated properties are not required for deletion. Gzipped JSON payloads and CSV payloads are also supported for this endpoint, similar to the add/update multiple min-max data elements endpoint. Be sure to set the appropriate headers (Content-Encoding as gzip and Content-Type as application/csv or application/json) when sending the request. If using CSV, you will also need to specify the dataSet query parameter in the request URL.
锁定异常¶
锁定异常资源允许您打开其他锁定的数据 用于特定数据集、时期和组织的数据输入集 单元。您可以从以下资源中读取锁定异常:
/ api / lockExceptions
# HELP data_summary_object_counts 元数据对象计数
# TYPE data_summary_object_counts gauge
data_summary_object_counts{type="indicator"}77
data_summary_object_counts{type="trackedEntity"} 7312573125
data_summary_object_counts{type="visualization"}292
data_summary_object_counts{type="period"} 384384
data_summary_object_counts{type="programStageInstance"} 373597373597
POST / api / lockExceptions?ds = BfMAe6Itzgt&pe = 201709&ou = DiszpKrYNg8
要删除锁定异常,您可以使用类似的请求语法 删除请求:
# HELP data_summary_build_info 建立信息
# TYPE data_summary_build_info gauge
data_summary_build_info{version="2.42-SNAPSHOT", commit="932e552"}1737621197
Data summary { #webapi_data_statistics}
The data summary resource provides some metrics about the database and level of system usage. The metrics include: Data statistics can be accessed with a GET request to :