Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Object Storage
    • All tutorials
      • Getting statistics on object queries with S3 Select
      • Getting website traffic statistics with S3 Select
      • Analyzing logs in DataLens
      • Getting statistics on object queries using Yandex Query
      • Storing application runtime logs
      • Searching for Yandex Cloud events in Object Storage
      • Uploading audit logs to ArcSight SIEM
      • Replicating logs to Object Storage using Fluent Bit
      • Replicating logs to Object Storage using Data Streams
      • Uploading audit logs to Splunk SIEM
      • Searching for Yandex Cloud events in Yandex Query
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Bucket logs
  • Release notes
  • FAQ

In this article:

  • Getting started
  • Getting visit statistics
  1. Tutorials
  2. Log collection and analysis
  3. Getting website traffic statistics with S3 Select

Getting website traffic statistics with S3 Select

Written by
Yandex Cloud
Updated at November 10, 2026
View in Markdown
  • Getting started
  • Getting visit statistics

Get statistics on queries to objects within a bucket configured to host a static website. Use the S3 Select query language to get data.

Note

To get information about queries, 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 requests to the website grouped by browsers and other request clients (by the user_agent field), run an aggregation query using the sort and uniq commands:

    sort output.csv | uniq -c | sort -nr
    

    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
    
  3. To display the number of hits for each page:

    1. Update the expression in the $query variable:

      query="select object_key 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"
      
    3. Run the aggregation query:

      sort output.csv | uniq -c | sort -nr
      

      Result:

      418 index.html
      255 about.html
      101 images/logo.png
      17 css/style.css
      

Was the article helpful?

Previous
Getting statistics on object queries with S3 Select
Next
Overview
© 2026 Direct Cursus Technology L.L.C.