github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/point_window.en.md (about)

     1  ### `point_window()` {fn-point-window}
     2  
     3  Function prototype: `fn point_window(before: int, after: int, stream_tags = ["filepath", "host"])`
     4  
     5  Function description: Record the discarded data and use it with the `window_hit` function to upload the discarded context `Point` data.
     6  
     7  Function parameters:
     8  
     9  - `before`: The maximum number of points that can be temporarily stored before the function `window_hit`  is executed, and the data that has not been discarded is included in the count.
    10  - `after`: The number of points retained after the `window_hit` function is executed, and the data that has not been discarded is included in the count.
    11  - `stream_tags`: Differentiate log (metrics, tracing, etc.) streams by labels on the data, the default number using `filepath` and `host` can be used to distinguish logs from the same file.
    12  
    13  Example:
    14  
    15  ```python
    16  # It is recommended to place it in the first line of the script
    17  #
    18  point_window(8, 8)
    19  
    20  # If it is a panic log, keep the first 8 entries 
    21  # and the last 8 entries (including the current one)
    22  #
    23  if grok(_, "abc.go:25 panic: xxxxxx") {
    24      # This function will only take effect if point_window() is executed during this run.
    25      # Trigger data recovery behavior within the window
    26      #
    27      window_hit()
    28  }
    29  
    30  # By default, all logs whose service is test_app are discarded;
    31  # If it contains panic logs, keep the 15 adjacent ones and the current one.
    32  #
    33  if service == "test_app" {
    34      drop()
    35  }
    36  ```