Giter VIP home page Giter VIP logo

search-logger's Introduction

search-logger

This is a tool which logs user searches to our "reporting" Elasticsearch cluster. These logs include:

  • what search term somebody typed in
  • how many results we returned
  • which results (if any) that they clicked on.

We use this to analyse search behaviour and improve our queries. For example, we can look at searches that return 0 results and discuss whether there really are no results, or whether we should change the results we return.

How search events get logged

flowchart LR
    W[website] --> S[Segment]
    S[Segment] --> K[Kinesis stream]
    K --> L[search logger Lambda]
    L --> R[(reporting<br/>cluster)]

    classDef externalNode fill:#e8e8e8,stroke:#8f8f8f
    class S,R,W externalNode

    classDef repoNode fill:#c8ecee,stroke:#298187,stroke-width:2px
    class K,L repoNode

Our website sends tracking events to Segment. Those segments are forwarded to a Kinesis data stream, which triggers a Lambda function. That Lambda function writes the search logs into the reporting cluster.

This repo contains:

  • the source code for the Lambda function
  • the Terraform definitions for the Kinesis stream and the Lambda function

Developer info

  • To deploy a new version the function:

    $ cd lambda
    $ yarn deploy
    $ cd ../terraform
    $ ./run_terraform.sh apply
  • You can see the Lambda logs in the logging cluster.

search-logger's People

Contributors

alexwlchan avatar jamesgorrie avatar kenoir avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

search-logger's Issues

Create an alarm on the Kinesis stream for GetRecords.IteratorAge

Earlier this week, the Lambda got stuck and stopped processing records from Kinesis into Elasticsearch. The Lambda was timing out; we fixed it by increasing the Lambda timeout โ€“ but we only noticed because we were looking at the reporting cluster and noticed the lack of search information.

Screenshot 2023-05-25 at 09 25 28

We could be alerted to this in future by creating an alarm on the GetRecords.IteratorAge metric, and sending a Slack alert when it goes above 0 โ€“ this means records aren't being processed off the stream. The graph above shows how this metric spiked when we had the outage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.