1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790
| # 列出所有索引 GET _cat/indices
# 查看indices GET /_cat/indices/jz-fe*?v&s=index
# 查看索引的文档总数 GET jz-fe-http-log/_count # 删除索引 # DELETE /jz-fe-http-log # 查看索引相关信息 GET nginx-log-bjdaojiacom-2019.07.20 GET jz-fe-http-log # 创建索引,禁止自动添加类型字段 PUT /jz-fe-http-log { "mappings": { "dynamic": "strict", "properties":{ "gitGroup":{"type":"keyword"}, "projectName":{"type":"keyword"}, "level":{"type":"keyword"}, "code":{"type":"keyword"}, "href":{"type":"text"}, "url":{ "type" : "text", "fields" : { "keyword" : { "type" : "keyword" } } }, "method":{"type":"keyword"}, "param":{"type":"text"}, "response":{"type":"text"}, "message":{ "type":"text", "fields" : { "keyword" : { "type" : "keyword" } }}, "stack":{"type":"text"}, "clientDate":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"}, "serverDate":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"}, "uid": {"type":"keyword"}, "phone": {"type":"keyword"}, "os":{"type":"text"}, "platform":{"type":"text"}, "browser":{"type":"keyword"}, "version":{"type":"keyword"}, "userAgent":{"type":"text"}, "status":{"type":"integer"}, "closeDate":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"} } } }
# 更新索引-增加字段 PUT jz-fe-http-log/_mapping { "dynamic": "strict", "properties": { "status":{"type":"integer"}, "closeDate":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"} } }
# 更新索引-修改字段 PUT jz-fe-http-log/_mapping { "properties": { "url":{ "type":"text", "fields" : { "keyword" : { "type" : "keyword" } }} } }
# 增加数据 POST /jz-fe-http-log/_doc { "os":"OS X", "platform":"iPhone", "browser":"Safari", "version":"11.0", "clientDate":"2019-08-23 18:54:03" }
# 指定key查询 GET /jz-fe-http-log/_search { "query": { "match": { "_id": "BYG_SG0BW-qMNGXgwzPg" } } }
# 按文档ID更新指定字段数据 POST /jz-fe-http-log/_doc/R9Wm_mwBAl5tA0U3Hq4l/_update { "doc" : { "status": 1 } }
# 按id删除数据 DELETE /jz-fe-http-log/_doc/l0_772wBAl5tA0U3dpBH # 删除指定查询数据 - 前缀匹配 # POST /jz-fe-http-log/_delete_by_query POST /jz-fe-http-log/_delete_by_query { "size":5, "query": { "regexp": { "projectName": "daily-clean-v2.+" } } }
POST /jz-fe-http-log/_delete_by_query { "size":5, "query": { "match": { "projectName": "<%- 909275197+844400363 %>" } } }
# 异常总数 GET /jz-fe-http-log/_search { "size":0, "query": { "match_all": {} } }
# 已处理异常总数 GET /jz-fe-http-log/_search { "size":0, "query": { "match": { "status": 1 } } }
# 当天异常总数 GET /jz-fe-http-log/_search { "size":0, "query": { "match": { "serverDate": "now/1d" } } }
# 今日异常数 POST /jz-fe-http-log/_search { "size":0, "query": { "bool": { "must": [ { "match": { "serverDate": "now/1d" }}, { "match": { "status": "1" }} ] } } }
# 按照项目名称分组 GET jz-fe-http-log/_search { "size":0, "query": { "bool": { "must": [ { "range": { "serverDate": { "gte": "2019-10-30 14:57:00", "lte": "2019-10-31 14:57:00" } } } ] } }, "aggs": { "group_by_projectName": { "terms": { "size": 50, "field": "projectName" } } } }
# 按照git group+项目名称分组 GET jz-fe-http-log/_search { "size":0, "aggs": { "group_by_gitGroup": { "terms": { "size": 50, "field": "gitGroup" }, "aggs": { "group_by_projectName": { "terms": { "size": 50, "field": "projectName" } } } } } }
# 指定项目下,错误等级分组 GET jz-fe-http-log/_search { "size":0, "query": { "match": { "projectName": "daily-clean" } }, "aggs": { "group_by_projectName": { "terms": { "field": "level" } } } }
# 按天分组、计数 GET jz-fe-http-log/_search { "size":0, "aggs": { "grouy_by_day": { "date_histogram": { "field": "serverDate", "interval": "day", "format" : "yyyy-MM-dd" } } } }
# 最近一周所有问题增长趋势 GET jz-fe-http-log/_search { "size":0, "track_total_hits": 100000, "query": { "bool": { "must": [ { "range": { "serverDate": { "gte": "2019-10-30 14:57:00", "lte": "2019-10-31 14:57:00" } } } ] } }, "aggs": { "grouy_by_hour": { "date_histogram": { "field": "serverDate", "interval": "hour", "format" : "yyyy-MM-dd HH:mm:ss" } } } }
# 上一周指定项目的问题增长趋势 GET jz-fe-http-log/_search { "size":1, "query": { "bool": { "must": [ { "match": { "projectName": "daily-clean" }}, { "range": { "serverDate": { "gte": "2019-10-30 14:57:00", "lte": "2019-10-31 14:57:00" } } } ] } }, "aggs": { "grouy_by_hour": { "date_histogram": { "field": "serverDate", "min_doc_count": 0, "interval": "hour", "format" : "yyyy-MM-dd HH:mm:ss" } } } }
# 指定项目,按message分组 GET jz-fe-http-log/_search { "size":0, "query": { "bool": { "must": [ { "match": { "projectName": "csworker" }} ] } }, "aggs": { "grouy_by_message": { "terms": { "size": 25, "field": "message.keyword" } } } }
# 按指定项目中的message分页查询 POST /jz-fe-http-log/_search { "size":2, "from": 0, "query": { "bool": { "must": [ { "match": { "projectName": "daily-clean" }}, { "match": { "message.keyword": "无可用商家" }} ] } } }
# 指定项目+message,按url分组,查询出指定错误的url排行 POST /jz-fe-http-log/_search { "size":0, "from": 0, "query": { "bool": { "must": [ { "match": { "projectName": "daily-clean" }}, { "match": { "message.keyword": "timeout of 5000ms exceeded" }} ] } }, "aggs": { "group_by_url": { "terms": { "field": "url.keyword" } } } }
# 按时间降序 POST /jz-fe-http-log/_search { "size":1, "query": { "bool": { "must": [ { "match": { "projectName": "daily-clean" }}, { "match": { "message.keyword": "无可用商家" }} ] } }, "sort": [ {"serverDate": "desc"} , {"_id": "asc"} ] }
# 按时间降序-searchAfter POST /jz-fe-http-log/_search { "size":1, "query": { "bool": { "must": [ { "match": { "projectName": "daily-clean" }}, { "match": { "message.keyword": "无可用商家" }} ] } }, "search_after":[ 1569489763000, "NP4pa20BFerq1YvUydLx" ], "sort": [ {"serverDate": "desc"} , {"_id": "asc"} ] }
# 指定时间段,按项目分组 GET jz-fe-http-log/_search { "size":0, "query": { "range": { "serverDate": { "gt": "2019-09-24 09:00:00", "lt": "2019-09-24 10:00:00", "format": "yyyy-MM-dd HH:mm:ss" } } }, "aggs": { "grouy_by_project": { "terms": { "field": "projectName" } } } }
# 查询最近一小时的数据,按项目分组 GET jz-fe-http-log/_search { "size":0, "query": { "bool": { "must": [ { "range": { "serverDate": { "gte": "2019-10-31 12:57:00", "lte": "2019-10-31 13:57:00" } } } ] } }, "aggs": { "grouy_by_project": { "terms": { "size": 100, "field": "projectName" } } } }
# 异常查询 GET jz-fe-http-log/_search { "size":30, "query": { "bool": { "must": [
{ "range": { "serverDate": { "gte": "2020-01-18 17:00:00", "lte": "2020-01-18 17:30:00" } } } ] } }, "aggs": { "grouy_by_project": { "terms": { "size": 100, "field": "projectName" } } } }
GET jz-fe-http-log/_search { "size":0, "query": { "bool": { "must": [ { "match": { "projectName": "daily-clean-v2" }}, { "range": { "serverDate": { "gte": "2020-01-18 07:00:00", "lte": "2020-01-18 13:00:00" } } } ] } }, "aggs": { "grouy_by_message": { "terms": { "size": 25, "field": "message.keyword" } } } }
GET jz-fe-http-log/_search { "size":0, "query": { "bool": { "must": [ { "match": { "projectName": "daily-clean-v2" }}, { "range": { "serverDate": { "gte": "2020-01-18 07:00:00", "lte": "2020-01-18 13:00:00" } } } ] } }, "aggs": { "group_by_url": { "terms": { "field": "url.keyword" } } } }
# ---------------------------------------------------------------------------- # 性能监控相关 # ---------------------------------------------------------------------------- # 查看索引相关信息 GET jz-fe-performance-log # 查看索引的文档总数 GET jz-fe-performance-log/_count # 删除索引 DELETE /jz-fe-performance-log # 性能监控-创建索引,禁止自动添加类型字段 PUT /jz-fe-performance-log { "mappings": { "dynamic": "strict", "properties":{ "groupName":{"type":"keyword"}, "projectName":{"type":"keyword"}, "href":{"type":"keyword"}, "clientDate":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"}, "serverDate":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"}, "appId":{"type":"keyword"}, "hmsr":{"type":"keyword"}, "znsr":{"type":"keyword"}, "hmpl":{"type":"keyword"}, "unloadTime":{"type":"integer"}, "redirectTime":{"type":"integer"}, "appCacheTime":{"type":"integer"}, "dnsTime":{"type":"integer"}, "tcpTime":{"type":"integer"}, "requestTime":{"type":"integer"}, "responseTime":{"type":"integer"}, "analysisTime":{"type":"integer"}, "loadEventTime":{"type":"integer"}, "connectTime":{"type":"integer"}, "resourceTime":{"type":"integer"}, "domReadyTime":{"type":"integer"}, "TTFBTime":{"type":"integer"}, "TTSRTime":{"type":"integer"}, "TTDCTime":{"type":"integer"}, "TTFLTime":{"type":"integer"}, "uid":{"type":"keyword"}, "phone":{"type":"keyword"}, "platform":{"type":"keyword"}, "os":{"type":"keyword"}, "browser":{"type":"keyword"}, "version":{"type":"keyword"}, "userAgent":{"type":"text"}, "ip":{"type":"keyword"}, "networkType":{"type":"keyword"}, "ISP":{"type":"keyword"}, "region":{"type":"keyword"} } } }
# 查询索引下的所有数据 GET /jz-fe-performance-log/_search { "query": { "match_all": {} } }
# 查看索引详情 GET /_cat/indices/jz-fe*?v&s=index # 删除后释放空间 POST jz-fe-performance-log/_forcemerge # 删除指定时间段的数据 POST jz-fe-performance-log/_delete_by_query?scroll_size=10000&slices=10 { "query": { "bool": { "must": [ { "range": { "serverDate": { "lte": "2020-01-01 00:00:00" } } } ] } } }
# 查询出指定时间段项目的平均打开时间 GET jz-fe-performance-log/_search { "size":0, "track_total_hits": 10000000, "query": { "bool": { "must": [ { "range": { "serverDate": { "gte": "2020-01-10 12:00:00", "lte": "2020-01-18 13:00:00" } } } ] } }, "aggs":{ "projectAvgTime":{ "terms":{ "size": 50, "script": "'【'+doc['groupName'].value+'】'+doc['projectName'].value", "order": { "avgTime": "desc" } }, "aggs":{ "avgTime":{ "avg":{ "field":"TTFLTime" } }, "minTime":{ "min":{ "field":"TTFLTime" } }, "maxTime":{ "max":{ "field":"TTFLTime" } } } } } }
# 秒开率计算 POST jz-fe-performance-log/_search { "size": 0, "track_total_hits": 10000000, "query": { "bool": { "must": [ { "range": { "TTFLTime": { "lte": 3000 } } }, { "match": { "projectName": "daily-clean-v2" }}, { "range": { "serverDate": { "gte": "2020-01-10 12:00:00", "lte": "2020-01-18 13:00:00" } } } ] } } }
# 平均首字节时间 GET jz-fe-performance-log/_search { "size":0, "track_total_hits": 10000000, "query": { "bool": { "must": [ { "range": { "serverDate": { "gte": "2020-01-10 12:00:00", "lte": "2020-01-18 13:00:00" } } } ] } }, "aggs":{ "avgTime":{ "avg":{ "field":"TTFLTime" } }, "minTime":{ "min":{ "field":"TTFLTime" } }, "maxTime":{ "max":{ "field":"TTFLTime" } } } }
# 性能柱状图 GET jz-fe-performance-log/_search { "size":0, "track_total_hits": 10000000, "query": { "bool": { "must": [ { "range": { "TTFLTime": { "gte": 250, "lte": 349 } } }, { "range": { "serverDate": { "gte": "2020-02-05 16:19:19", "lte": "2020-02-06 16:19:19" } } } ] } }, "aggs":{ "chartData":{ "terms":{ "size": 1000, "field": "TTFLTime", "script": "Math.round(_value/100)", "order": { "_key": "asc" } } } } }
|
留言
欢迎交流想法。留言会通过 GitHub Issues 保存,首次使用需要登录 GitHub。