监控:API

概述

Geonode监视是一种可选的基础架构,用于监视GeoNode中的资源使用情况,随附在运行每项服务的Geoserver和主机上。这不是像zabbix或Nagios那样的全面监控,而是用于诊断部署健康的中等大小的工具。它将由大多数不是全职sysop的用户使用,因此使用起来很简单。

API

监控API向监控客户端公开各种数据。

接口根URL为 /monitoring/ ,本文档中的每个路径都是相对于该根目录的。

有效自/有效至

监控以固定周期(通常为1分钟)定期收集数据。每个指标数据都是在该时间段内累积的值(如果按其他指标划分,如资源、标签等,则为一个或多个值)。

主机

主机是正在运行特定服务(GeoNode或Geoserver)的物理或虚拟实例。此实体不受监视,但用于按部署位置对服务进行分组。主机列表在以下位置的API中提供 /api/hosts/ 端点:

GET /monitoring/api/hosts/

{
  "hosts": [
    {
      "ip": "127.0.0.1",
      "name": "localhost"
    }
  ]
}

虽然不直接监视主机,但某些服务类型(以及这些类型的服务)负责监视底层主机,间接监视硬件资源(不需要专用的系统级代理)。

服务

服务是被监控服务的名称。服务可从管理界面配置,并在 /api/services/

GET /monitoring/api/services/

{
  "services": [
    {
      "name": "local-system",
      "last_check": "2017-08-03T13:33:26.674",
      "host": "localhost",
      "check_interval": 60,
      "type": "hostgeonode",
      "id": 3
    },
    {
      "name": "local-geoserver",
      "last_check": "2017-08-03T13:33:26.455",
      "host": "localhost",
      "check_interval": 60,
      "type": "geoserver",
      "id": 2
    },
    {
      "name": "local-geonode",
      "last_check": "2017-08-03T13:33:27.741",
      "host": "localhost",
      "check_interval": 60,
      "type": "geonode",
      "id": 1
    }
  ]
}

每项服务都由属性描述:

  • name -服务的唯一名称

  • type -服务类型名称

  • host -运行服务的主机

  • id -对象ID

  • last_check -该服务上一次检查(数据收集)的时间戳

  • check_interval -间隔(秒),应从该服务收集数据的频率。

服务类型

服务类型描述了它被分配到的服务类型。有几种可用的服务类型:

  • geonode -服务为GeoNode实例

  • geoserver -服务是Geoserver实例

  • hostgeonode -服务不是应用程序,服务是使用GeoNode测量的底层主机(请参见 主机 )

  • hostserver -服务不是应用程序,服务是使用Geoserver测量的底层主机(请参见 主机 )

资源

资源是可以由GeoNode或Geoserver提供服务的对象。有几种受监控的资源类型:

  • 图层

  • 文档

  • 地图

  • URL

资源可以从GeoNode或Geoserver提供。我们不检查具体的资源是否实际存在,只保留使用和记录的项目列表以供监控。此外,它不会显示同一资源的重命名/副本/移动。

资源列表位于 /api/resources/ 端点:

GET /monitoring/api/resources/

{
  "resources": [
    {
      "type": "layer",
      "id": 13,
      "name": "unesco:Unesco_point"
    },
    {
      "type": "layer",
      "id": 7,
      "name": "geonode:test"
    },
    {
      "type": "layer",
      "id": 14,
      "name": "http://www.opengis.net/gml:GridCoverage"
    },
    {
      "type": "map",
      "id": 17,
      "name": "some map"
    },
    ]
}

资源使用以下属性进行描述:

  • id -监控中的资源记录的数字ID

  • type -资源类型

  • name -资源名称。

可以使用以下查询字符串参数筛选资源列表:

  • metric_name -应返回其资源的指标名称

  • resource_type -资源类型名称 (layermapdocumentstyleurl )

  • valid_from -列出自该时间戳以来可用的资源

  • valid_to -列出该时间戳之前可用的资源

示例:

GET /monitoring/api/resources/?resource_type=layer&metric_name=request.count&valid_from=2017-08-01

{
  "resources": [
    {
      "type": "layer",
      "id": 24,
      "name": "atlantis:landmarks"
    },
    {
      "type": "layer",
      "id": 2,
      "name": "topp:states"
    },
    {
      "type": "layer",
      "id": 22,
      "name": "atlantis:island"
    },
    {
      "type": "layer",
      "id": 23,
      "name": "atlantis:poi"
    },
    {
      "type": "layer",
      "id": 16,
      "name": "dissolveroad2"
    },
    {
      "type": "layer",
      "id": 21,
      "name": "atlantis:roads"
    }
  ]
}

资源类型

资源类型描述GeoNode监视考虑的资源类型。要检索资源类型的完整列表,请使用 /api/resource_types/ 可用:

GET /monitoring/api/resource_types/

{
  "status": "ok",
  "data": {
    "key": "resource_types"
  },
  "errors": {},
  "resource_types": [
    {
      "type": "No resource",
      "name": ""
    },
    {
      "type": "Layer",
      "name": "layer"
    },
    {
      "type": "Map",
      "name": "map"
    },
    {
      "type": "Resource base",
      "name": "resource_base"
    },
    {
      "type": "Document",
      "name": "document"
    },
    {
      "type": "Style",
      "name": "style"
    },
    {
      "type": "Admin",
      "name": "admin"
    },
    {
      "type": "URL",
      "name": "url"
    },
    {
      "type": "Other",
      "name": "other"
    }
  ],
  "success": true
}

事件类型

事件类型描述GeoNode中资源的使用方式。资源可以作为常规视图进行访问(通过GeoNode,如 /layers/X URL),或通过OWS请求。有关已处理的事件类型的完整列表,请参阅 /api/event_types/ 端点:

GET /monitoring/api/event_types/

{
    "status": "ok",
    "errors": { },
    "data": {
        "key": "event_types"
        },
    "event_types": [
        {
            "name": "all"
            },
        {
            "name": "other"
            },
        {
            "name": "download"
            },
        {
            "name": "view"
            },
        {
            "name": "OWS:TMS"
            },
        {
            "name": "OWS:WMS-C"
            },
        {
            "name": "OWS:WMTS"
            },
        {
            "name": "OWS:WCS"
            },
        {
            "name": "OWS:WFS"
            },
        {
            "name": "OWS:WMS"
            },
        {
            "name": "OWS:WPS"
            },
        {
            "name": "OWS:ALL"
            },
        {
            "name": "create"
            },
        {
            "name": "upload"
            },
        {
            "name": "change"
            },
        {
            "name": "change_metadata"
            },
        {
            "name": "view_metadata"
            },
        {
            "name": "publish"
            },
        {
            "name": "remove"
            }
        ],
    "success": true
}

以开头的事件类型 OWS: 前缀表示它们与OWS服务相关。 OWS:ALL 是一个累积事件类型,它保存对任何OWS的请求。

事件类型 other 表示与OWS无关的请求。这也是累积事件类型,应该用作所有非OWS请求的基线。

In order to retrieve OWS only requests the ows-service flag (possible values are True, true, False, false, 0, 1) can be used:

  • OWS 事件类型

    GET /monitoring/api/event_types/?ows_service=true

    {
      "status": "ok",
      "errors": {},
      "data": {
        "key": "event_types"
      },
      "event_types": [
        {
          "name": "OWS:TMS",
          "type_label": "TMS"
        },
        {
          "name": "OWS:WMS-C",
          "type_label": "WMS-C"
        },
        {
          "name": "OWS:WMTS",
          "type_label": "WMTS"
        },
        {
          "name": "OWS:WCS",
          "type_label": "WCS"
        },
        {
          "name": "OWS:WFS",
          "type_label": "WFS"
        },
        {
          "name": "OWS:WMS",
          "type_label": "WMS"
        },
        {
          "name": "OWS:WPS",
          "type_label": "WPS"
        },
        {
          "name": "OWS:ALL",
          "type_label": "Any OWS"
        }
      ],
      "success": true
    }
    
  • non-OWS 事件类型

    GET /monitoring/api/event_types/?ows_service=false

    {
      "status": "ok",
      "errors": {},
      "data": {
        "key": "event_types"
      },
      "event_types": [
        {
          "name": "other",
          "type_label": "Not OWS"
        },
        {
          "name": "all",
          "type_label": "All"
        },
        {
          "name": "create",
          "type_label": "Create"
        },
        {
          "name": "upload",
          "type_label": "Upload"
        },
        {
          "name": "change",
          "type_label": "Change"
        },
        {
          "name": "change_metadata",
          "type_label": "Change Metadata"
        },
        {
          "name": "view_metadata",
          "type_label": "View Metadata"
        },
        {
          "name": "view",
          "type_label": "View"
        },
        {
          "name": "download",
          "type_label": "Download"
        },
        {
          "name": "publish",
          "type_label": "Publish"
        },
        {
          "name": "remove",
          "type_label": "Remove"
        },
        {
          "name": "geoserver",
          "type_label": "Geoserver event"
        }
      ],
      "success": true
    }
    

事件类型 all 指任何请求。

标签

标签是对未由资源描述的度量数据子集的描述(它不作为逻辑数据集)。可以用标签描述的东西:

  • 用户跟踪ID

  • 卷装入点

  • 网络接口名称

  • 请求路径

  • 请求方法

  • 响应状态代码

  • 等等。

记录的所有标签的列表可在 /api/labels/ 端点:

GET /monitoring/api/labels/

{
  "labels": [
    {
      "id": 306,
      "name": "Other / Other / Python Requests 2.13"
    },
    {
      "id": 315,
      "name": "Kent"
    },
    {
      "id": 298,
      "name": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
    },
    {
      "id": 261,
      "name": "lo"
    },
    {
      "id": 331,
      "name": "PUT"
    },
    {
      "id": 334,
      "name": "Other / Other / Python Requests 2.18"
    }
    ]
}

每个度量数据集将至少附加一个标签。可以使用以下查询字符串参数筛选标签列表:

  • metric_name -应返回标签的指标名称

  • valid_from -列出自该时间戳以来可用的标签

  • valid_to -列出在该时间戳之前可用的标签

示例:

GET /monitoring/api/labels/?metric_name=request.ua&valid_from=2017-08-05

{
  "labels": [
    {
      "id": 298,
      "name": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
    },
    {
      "id": 312,
      "name": "Java/1.8.0_131"
    },
    {
      "id": 293,
      "name": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36"
    },
    {
      "id": 345,
      "name": "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1"
    },
    ...
   ]
}

指标名称

指标名称是指标存储的数据类型的半命名空间描述。典型指标名称:- request.count - request.ip - response.size - response.status

每种服务类型都有一组可用的指标。应用程序级别的服务将具有与主机级别服务不同的指标集。

有关指标的完整列表,请参阅 /api/metrics/ 端点。返回的列表不可筛选。回复示例:

GET /monitoring/api/metrics/

{
  "metrics": [
    {
      "metrics": [
        {
          "type": "count",
          "name": "request.count",
          "unit": "Count"
        },
        {
          "type": "count",
          "name": "request.ip",
          "unit": "Count"
        },
        ...
      ],
      "service": "geonode"
    },
    { "service": "geoserver",
      "metrics": [..]
    }
    ]
}

指标按服务分组。每个指标具有以下结构:

{
    "type": "count",
    "name": "request.ip",
    "unit": "Count"
}

其中:

  • type 是度量数据类型(可以是计数、值或速率)。这是如何处理指标数据聚合的内部描述。

  • name 指标名称

  • unit 建议的Y轴标签,描述数据单元

指标数据

监控API的核心功能是能够获取指定时间段内给定指标的数据。度量值是固定时间段的数据集,从中收集并处理特定指标名称的数据。此外,每个指标都可以计算特定服务、资源、标签和EVENT_TYPE的数据。度量数据API具有以下几个功能:

  • 它可以显示特定时间范围内的度量数据,精确到1分钟(如果收集间隔较短,可能会更小)。

  • 它可以显示以自定义粒度聚合的度量数据(例如,过去48小时的15分钟粒度)。

  • 它可以显示整个受监视设置或特定资源、标签(如用户代理类型)、受监视服务(仅适用于Geonode或仅适用于Geoserver)、事件类型的度量数据。参数可以在一个查询中联接。

API端点为: /api/metric_data/METRIC_NAME/

以下项目的样本请求 request.ua 具体时间窗指标(2017-08-03上午10点至下午2点)和数据粒度(1h)

GET /monitoring/api/metric_data/request.ua/?
valid_from=2017-08-03%2010:00:00&valid_to=2017-08-03%2014:00:00&interval=3600
{
  "data": {
    "input_valid_from": "2017-08-03T10:00:00",
    "input_valid_to": "2017-08-03T14:00:00",
    "data": [
      {
        "valid_from": "2017-08-03T10:00:00",
        "data": [],
        "valid_to": "2017-08-03T11:00:00"
      },
      {
        "valid_from": "2017-08-03T11:00:00",
        "data": [
          {
            "samples_count": 10,
            "val": "10.0000",
            "min": "1.0000",
            "max": "1.0000",
            "sum": "10.0000",
            "label": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0",
            "metric_count": 10
          },
          {
            "samples_count": 790,
            "val": "790.0000",
            "min": "19.0000",
            "max": "79.0000",
            "sum": "790.0000",
            "label": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
            "metric_count": 22
          },
          {
            "samples_count": 150,
            "val": "150.0000",
            "min": "15.0000",
            "max": "15.0000",
            "sum": "150.0000",
            "label": "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1",
            "metric_count": 10
          }
        ],
        "valid_to": "2017-08-03T12:00:00"
      },
      {
        "valid_from": "2017-08-03T12:00:00",
        "data": [],
        "valid_to": "2017-08-03T13:00:00"
      },
      {
        "valid_from": "2017-08-03T13:00:00",
        "data": [
          {
            "samples_count": 37,
            "val": "37.0000",
            "min": "4.0000",
            "max": "12.0000",
            "sum": "37.0000",
            "label": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.40 Safari/537.36",
            "metric_count": 4
          }
        ],
        "valid_to": "2017-08-03T14:00:00"
      }
    ],
    "metric": "request.ua",
    "interval": 3600,
    "type": "count",
    "axis_label": "Count",
    "label": null
  }
}

指标数据响应用以下信封封装:

    "data": {
        "input_valid_from": "2017-08-03T10:00:00",
        "input_valid_to": "2017-08-03T14:00:00",
        "metric": "request.ua",
        "interval": 3600,
        "type": "count",
        "axis_label": "Count",
        "label": null,
        "data": [
        ... # actual data
        ],
    }
}

其中:

  • input_valid_frominput_valid_to 为其返回数据的已解析和对齐的时间戳,

  • metric 是返回响应的指标名称,

  • interval 使用的数据聚合间隔,以秒为单位(如果未提供,则使用60秒,除非时间窗口大于24小时),

  • type 是指标数据类型,内部描述如何聚合数据(SUM、Average或Min/Max函数)。

  • axis_label 是否建议在图表中使用值轴标签

  • label 是否使用度量数据标签(默认情况下没有标签)。

度量数据项构建为以下结构:

{
    "valid_from": "2017-08-03T13:00:00",
    "valid_to": "2017-08-03T14:00:00",
    "data": [
    {
        "samples_count": 37,
        "val": "37.0000",
        "min": "4.0000",
        "max": "12.0000",
        "sum": "37.0000",
        "label": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.40 Safari/537.36",
        "metric_count": 4
    },
    {
        "samples_count": 20,
        "val": "20.0000",
        "min": "4.0000",
        "max": "10.0000",
        "sum": "20.0000",
        "label": "Internet Explorer 4.0",
        "metric_count": 3
    },
    ],

}

其中:

  • valid_fromvalid_to 是数据聚合期的时间戳

  • data 是值行的列表。什么时候 data 为空,则表示没有为输入参数收集数据。

  • 每个人 data 元素包含:

    • label 与指标数据值关联的标签值。这可以描述用户提供的差异值(用户代理字符串、请求方法等),或者,如果没有使用这样的值,则可以描述默认值、“count”或“value”标签。

    • val 指标数据聚合值,需要前端应用使用。为 request.ua 这意味着给定用户代理字符串的请求计数, response.time 这将返回平均响应时间。

    • minmaxsum 是给出所用数据的洞察力的帮助器统计值,

    • samples_count 是用于此计算的所有样本计数(实际请求)的总和

    • metric_count 是用于计算值的多个度量数据。

    • resource (可选)具有资源结构的键 (idnametype )。使用按资源分组时,此元素将可见。

    • event_type (可选)键,事件类型名称与行的睡觉相关。使用按事件类型分组时,此元素将可见

可以使用以下参数筛选指标数据:

  • valid_from TIMESTAMP(DATE或DATE+TIME)表示数据应该比此时间戳新

  • valid_to 时间戳(日期或日期+时间)表示数据应早于此时间戳

  • interval 数据聚合间隔,以秒为单位。请参阅以下有关间隔和时间戳对齐的说明

  • label 仅应为其返回数据的标签值(请参见 [标签] (标签数)

  • resource 资源ID(请参见 [资源] (#RESOURCES))应返回的数据

  • service 服务名称(请参见 [服务] (#services))应返回哪些数据

  • event_type 服务名称(请参见 [事件类型] (#OWS_SERVICE))应该返回哪些数据

  • resource_type 过滤的资源类型名称,例如 layer 仅显示Layer对象的数据(不包括URL、文档、地图)。

对度量数据进行分组

此外,在某些情况下,客户端应用程序可能希望在一个周期内接收几个资源的数据点列表(典型使用场景:列出请求最多的层)。在这种情况下,还需要使用以下参数查询指标数据:

  • group_by -分组需要使用的Object名称。目前有两种分组模式可用:

    • resource -按受影响的资源分组。这将为同一标签生成指标,但每个受影响的资源将单独列出。返回的指标数据项将具有其他 resource 钥匙,它将容纳带有钥匙的字典 nametype 。回复示例:

      GET /monitoring/api/metric_data/request.count/?last=86400&interval=86400&group_by=resource

      {
        "data": {
          "input_valid_from": "2017-09-01T00:00:00",
          "input_valid_to": "2017-09-08T13:50:34.024",
          "data": [
            ..
            {
              "valid_from": "2017-09-04T00:00:00",
              "data": [
                {
                  "resource": {
                    "type": "layer",
                    "name": "nurc:Arc_Sample"
                  },
                  "samples_count": 300,
                  "val": "300.0000",
                  "min": "100.0000",
                  "max": "100.0000",
                  "sum": "300.0000",
                  "label": "count",
                  "metric_count": 3,
                  "id": 10
                },
                {
                  "resource": {
                    "type": "layer",
                    "name": "sde:HYP_HR_SR_OB_DR"
                  },
                  "samples_count": 72,
                  "val": "72.0000",
                  "min": "24.0000",
                  "max": "24.0000",
                  "sum": "72.0000",
                  "label": "count",
                  "metric_count": 3,
                  "id": 25
                }
              ],
              "valid_to": "2017-09-05T00:00:00"
            }
              ],
              "valid_to": "2017-09-09T00:00:00"
            }
          ],
          "metric": "request.count",
          "interval": 86400,
          "type": "count",
          "axis_label": "Count",
          "label": null
        }
      }
      
    • resource_no_labels -按受影响的资源分组,但不按标签区分。这将产生与其他分组类似的结果,但它将不包含“标签”键。

      GET /monitoring/api/metric_data/request.users/? last=86400&interval=86400&group_by=resource_no_label&event_type=view&resource_type=url

      {
          "data": {
              "input_valid_from": "2018-07-10T15:13:50.784Z",
              "input_valid_to": "2018-07-11T15:13:50.784Z",
              "data": [
                  {
                      "val"id_from: "2018-07-10T15:13:50.784Z",
                      "data": [
                  {
                      "resource": {
                          "type": "url",
                          "name": "/layers/",
                          "id": 15
                      },
                      "metric_count": 4,
                      "val": 2,
                      "min": "1.0000",
                      "max": "1.0000",
                      "sum": "4.0000",
                      "samples_count": 4
                  },
                  {
                      "resource": {
                          "type": "url",
                          "name": "/",
                          "id": 16
                      },
                      "metric_count": 4,
                      "val": 2,
                      "min": "1.0000",
                      "max": "4.0000",
                      "sum": "7.0000",
                      "samples_count": 7
                  },
                  {
                      "resource": {
                          "type": "url",
                          "name": "/maps/",
                          "id": 17
                      },
                      "metric_count": 4,
                      "val": 2,
                      "min": "1.0000",
                      "max": "2.0000",
                      "sum": "5.0000",
                      "samples_count": 5
                  },
                  {
                      "resource": {
                          "type": "url",
                          "name": "/maps/3",
                          "id": 18
                      },
                      "metric_count": 1,
                      "val": 1,
                      "min": "1.0000",
                      "max": "1.0000",
                      "sum": "1.0000",
                      "samples_count": 1
                  },
                  {
                      "resource": {
                          "type": "url",
                          "name": "/maps/7",
                          "id": 20
                      },
                      "metric_count": 1,
                      "val": 1,
                      "min": "1.0000",
                      "max": "1.0000",
                      "sum": "1.0000",
                      "samples_count": 1
                  }
                  ],
                  "valid_to": "2018-07-11T15:13:50.784Z"
              }
              ],
              "metric": "request.users",
              "interval": 86400,
              "type": "value",
              "axis_label": "Count",
              "label": null
          }
      }
      
    • label -按标签分组。这将返回选定期间内出现的唯一标签的数量。

      GET /monitoring/api/metric_data/request.users/?last=86400&interval=86400&group_by=label

      {
        "data": {
          "input_valid_from": "2018-07-10T16:29:08.982Z",
          "input_valid_to": "2018-07-11T16:29:08.982Z",
          "data": [
            {
              "valid_from": "2018-07-10T16:29:08.982Z",
              "data": [
                {
                  "samples_count": 243,
                  "val": 13,
                  "min": "0.0000",
                  "max": "25.0000",
                  "sum": "243.0000",
                  "metric_count": 124
                }
              ],
              "valid_to": "2018-07-11T16:29:08.982Z"
            }
          ],
          "metric": "request.users",
          "interval": 86400.0,
          "type": "value",
          "axis_label": "Count",
          "label": null
        }
      }
      
    • event_type -按事件类型分组。这会暴露出 event_type 数据项中的字段。分组将返回每个事件类型的请求数。

    • event_type_on_label -按事件类型分组,但使用Label进行分组(而不是指标数据值)。这会暴露出 event_type 数据项中的字段。分组将返回每个标签的请求数(特别是对于 request.users ,它使用标签字段作为跟踪id值,请参见 [用户分析] (https://github.com/geosolutions-it/geonode/wiki/Monitoring:-User-Analytics)).

时间戳对齐

通过监控收集的数据被聚合成固定的间隔值。这有几个后果:

  • 不能查询小于聚合期间的时间窗口

  • 查询时间窗口时,输入VALID_FROM和VALID_TO将与可能的实际VALID_FROM和VALID_TO值对齐。对齐从每天0:00时开始计算。为了获得最佳效果,您应该使用可以在没有提醒的情况下对齐的间隔。

  • 在某些情况下,时间戳对齐可能会产生比预期更多的行数。例如,假设客户端应用程序希望以5分钟为间隔聚合数据。搜索12:04到12:06之间的数据,即使这两个之间的间隔(2分钟)小于数据间隔(5分钟),这也将与数据间隔对齐,数据间隔将为:

    • 中午12时至12时05分

    • 从12时05分到12时10分

如果数据聚合期在将来结束,则很可能不包含任何数据。

例外情况

异常使用单独的API端点提供服务。这些端点将返回:

  • 捕获的异常列表

  • 异常详细信息

有关例外情况的列表,请参阅 /api/exceptions/ 端点:

GET /monitoring/api/exceptions/

{
  "exceptions": [
    {
      "url": "/monitoring/api/exceptions/8/",
      "error_type": "exceptions.ValueError",
      "id": 8,
      "service": {
        "type": "geonode",
        "name": "local-geonode"
      },
      "created": "2017-06-20T17:50:24.922"
    },
    {
      "url": "/monitoring/api/exceptions/9/",
      "error_type": "org.geoserver.platform.ServiceException",
      "id": 9,
      "service": {
        "type": "geoserver",
        "name": "local-geoserver"
      },
      "created": "2017-06-26T15:33:20.152"
    },
    {
      "url": "/monitoring/api/exceptions/10/",
      "error_type": "django.db.utils.ProgrammingError",
      "id": 10,
      "service": {
        "type": "geonode",
        "name": "local-geonode"
      },
      "created": "2017-06-27T12:32:37.032"
    },
  ]
}

列表中的每个例外包含:

  • error_type 这是一类例外

  • id 记录的给定异常的对象ID

  • ` service` 记录异常的服务对象

  • created 记录的异常时间戳

  • url 包含异常详细信息的URL

例外详细信息:

GET /monitoring/api/exceptions/30/

{
  "error_data": "Traceback (most recent call last):\n  File \"/home/cezio/.virtualenvs/geonode/lib/python2.7/site-packages/django/core/handlers/base.py\", line 132, in get_response\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\n  File \"/home/cezio/.virtualenvs/geonode/lib/python2.7/site-packages/django/views/generic/base.py\", line 71, in view\n    return self.dispatch(request, *args, **kwargs)\n  File \"/home/cezio/.virtualenvs/geonode/lib/python2.7/site-packages/django/views/generic/base.py\", line 89, in dispatch\n    return handler(request, *args, **kwargs)\n  File \"/mnt/work/cezio/geosolutions/repos/geonode/geonode/contrib/monitoring/views.py\", line 176, in get\n    return json_response({self.output_name: out})\n  File \"/mnt/work/cezio/geosolutions/repos/geonode/geonode/utils.py\", line 619, in json_response\n    body = json.dumps(body, cls=DjangoJSONEncoder)\n  File \"/usr/lib64/python2.7/json/__init__.py\", line 251, in dumps\n    sort_keys=sort_keys, **kw).encode(obj)\n  File \"/usr/lib64/python2.7/json/encoder.py\", line 207, in encode\n    chunks = self.iterencode(o, _one_shot=True)\n  File \"/usr/lib64/python2.7/json/encoder.py\", line 270, in iterencode\n    return _iterencode(o, 0)\n  File \"/home/cezio/.virtualenvs/geonode/lib/python2.7/site-packages/django/core/serializers/json.py\", line 115, in default\n    return super(DjangoJSONEncoder, self).default(o)\n  File \"/usr/lib64/python2.7/json/encoder.py\", line 184, in default\n    raise TypeError(repr(o) + \" is not JSON serializable\")\nTypeError: <Service: Service: local-geoserver@localhost> is not JSON serializable\n",
  "service": {
    "type": "geonode",
    "name": "local-geonode"
  },
  "created": "2017-07-24T13:29:28.321",
  "error_type": "exceptions.TypeError",
  "request": {
    "event_type": null,
    "client": {
      "ip": "127.0.0.1",
      "position": {
        "lat": null,
        "country": null,
        "lon": null,
        "city": null
      },
      "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.40 Safari/537.36",
      "user_agent_family": "PC / Linux / Chrome 60.0.3112"
    },
    "request": {
      "path": "/monitoring/api/exceptions/",
      "host": "localhost:8000",
      "method": "GET",
      "created": "2017-07-24T13:29:28.280"
    },
    "response": {
      "status": 200,
      "time": 30,
      "type": "text/html; charset=utf-8",
      "size": 0
    },
    "resources": []
  },
  "error_message": "exceptions.TypeError"
}

详细信息包括:

  • error_type 这是一类例外

  • error_message 提供的消息带有错误

  • error_data 是具有堆栈跟踪的纯文本

  • service 记录异常的服务对象

  • created 记录的异常时间戳

  • request 有关与此错误关联的请求的信息:

    • event_type 与请求关联的事件类型名称

    • client 请求客户端信息

    • request 有关收到的请求的详细信息

    • response 关于响应发回的详细信息

    • resources 受影响的资源列表

自动配置

自动配置端点允许根据以下条件执行监控配置 settings 价值。此API端点仅对超级用户/员工可用。回执用标准信封包装。

POST /monitoring/api/autoconfigure/

{
    "status": "ok",
    "success": true,
    "errors": {}
}