Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
      • Transferring a WordPress website from a different hosting provider to Yandex Cloud
      • Setting up virtual hosting
      • Creating a Python web application with Flask
      • Hosting a static Gatsby website
      • Migrating to Cloud CDN from a third-party CDN provider
      • Getting website traffic statistics using S3 Select

In this article:

  • Getting started
  • Getting visit statistics
  1. Application solutions
  2. Creating a website
  3. Getting website traffic statistics using S3 Select

Getting website traffic statistics using S3 Select

Written by
Yandex Cloud
Updated at April 18, 2025
  • Getting started
  • Getting visit statistics

Get the query statistics for objects within a bucket configured to host a static website. The data will be retrieved using the S3 Select query language.

Note

To get information about requests, enable logging for the bucket with the website content.

Getting startedGetting started

Install and configure the AWS CLI.

Getting visit statisticsGetting visit statistics

Bash
  1. Run the query against Object Storage and save the output to a file:

    1. For convenience, save:

      • Name of the bucket storing the object with the logs, to a variable named $bucket:

        bucket=<bucket_name>
        
      • Key of the object containing the logs, to a variable named $key:

        key=<object_key>
        
      • S3 Select expression to request the data, to a variable named $query:

        query="select user_agent from s3object"
        
    2. Run this command:

      aws --endpoint https://storage.yandexcloud.net s3api select-object-content \
        --bucket $bucket \
        --key $key \
        --expression "$query" \
        --expression-type 'SQL' \
        --input-serialization 'JSON={Type=LINES}' \
        --output-serialization 'CSV={}' \
        "output.csv"
      
  2. To display the number of hits for each page, run an aggregation query using the sort and uniq commands:

    sort -nr output.csv | uniq -c
    

    Result:

    418 docker/19.03.9 go/go1.13.10 git-commit/1d238398e7 kernel/4.4.0-142-generic os/linux arch/amd64 UpstreamClient(Go-http-client/1.1)
    255 docker/19.03.13 go/go1.13.15 git-commit/4484c46d9d kernel/3.10.0-1127.19.1.el7 os/linux arch/amd64 UpstreamClient(Go-http-client/1.1)
    101 aws-sdk-java/1.11.424 Linux/4.14.74-28+yc7 OpenJDK_64-Bit_Server_VM/11.0.5-shenandoah+10-adhoc.heretic.src java/11.0.5-shenandoah
    17 aws-cli/1.18.27 Python/2.7.6 Linux/4.19.62-13 botocore/1.17.50
    

Was the article helpful?

Previous
Migrating to Cloud CDN from a third-party CDN provider
Next
Overview
© 2025 Direct Cursus Technology L.L.C.