LogoLogo
AMPS Server Documentation 5.3.4
AMPS Server Documentation 5.3.4
  • Welcome to AMPS 5.3.4
  • Introduction to AMPS
    • Overview of AMPS
    • Getting Started With AMPS
      • Installing AMPS
      • Starting AMPS
      • JSON Messages - A Quick Primer
      • spark: the AMPS command-line client
      • Evaluating AMPS on Windows or MacOS
      • Galvanometer and RESTful Statistics
    • AMPS Basics: Subscribe and Publish to Topics
    • State of the World (SOW): The Message Database
      • When Should I Store a Topic in the SOW?
      • How Does the SOW Work?
      • Configuration
      • Queries
      • Atomic Query and Subscribe
      • Advanced Messaging and the SOW
    • Record and Replay Messages with the AMPS Transaction Log
    • Message Queues
    • Scenario and Feature Reference
      • Recovery Strategies
    • Getting Support
    • Advanced Topics
    • Next Steps
  • AMPS Evaluation Guide
    • Introduction
    • Evaluation and Development with AMPS
    • Tips on Measuring Performance
    • Next Steps
  • AMPS User Guide
    • Introduction
      • Product Overview
      • Requirements
      • Organization of this Guide
        • Documentation Conventions
      • Technical Support
    • Installing and Starting AMPS
      • Installing AMPS
      • Starting AMPS
      • Production Configuration
    • Subscribe and Publish
      • Topics
      • Filtering Subscriptions by Content
      • Conflated Subscriptions
      • Replacing Subscriptions
      • Messages in AMPS
      • Message Ordering
      • Retrieving Part of a Message
    • AMPS Expressions
      • Syntax
      • Identifiers
      • AMPS Data Types
      • Grouping and Order of Evaluation
      • Logical Operators
      • Arithmetic Operators
      • Comparison Operators
      • LIKE Operator
      • Conditional Operators
      • Working with Arrays
      • Regular Expressions
      • Performance Considerations
    • AMPS Functions
      • AMPS Function Overview
      • String Comparison Functions
      • Concatenating Strings
      • Managing String Case
      • Replacing Text in Strings
      • String Manipulation Functions
      • Date and Time Functions
      • Array Reduce Functions
      • Geospatial Functions
      • Numeric Functions
      • CRC Functions
      • Message Functions
      • Client Functions
      • Coalesce Function
      • AMPS Information Functions
      • Typed Value Creation
      • Constructing Fields
      • Aggregate Functions
    • State of the World (SOW) Topics
      • How Does the SOW Work?
      • Using the State of the World
      • Understanding SOW Keys
      • Indexing SOW Topics
      • Programmatically Deleting Records from the Topic State
      • SOW Maintenance
        • Creating a Maintenance Schedule for a Topic
        • Setting Per-Message Lifetime
      • Storing Multiple Logical Topics in One Physical Topic
    • Querying the State of the World (SOW)
      • Overview of SOW Queries
      • Query and Subscribe
      • Historical SOW Topic Queries
      • Managing Result Sets
      • Batching Query Results
    • Out-of-Focus Messages (OOF)
    • State of the World Message Enrichment
    • Incremental Message Updates
      • Using Delta Publish
      • Understanding Delta Publish
      • Delta Publish Support
    • Receiving Only Updated Fields
      • Using Delta Subscribe
      • Identifying Changed Records
      • Conflated Subscriptions and Delta Subscribe
      • Select List and Delta Subscribe
      • Options for Delta Subscribe
    • Conflated Topics
    • Aggregation and Analytics
      • Understanding Views
      • Defining Views and Aggregations
      • Constructing Field Contents
      • Best Practices for Views
      • View Examples
      • Aggregated Subscriptions
    • Record and Replay Messages
      • Using the Transaction Log and Bookmark Subscriptions
      • Understanding Message Persistence
      • Configuring a Transaction Log
      • Replaying Messages with Bookmark Subscription
      • Managing Journal Files
      • Using amps-grep to Search the Journal
    • Message Queues
      • Getting Started with AMPS Queues
      • Understanding AMPS Queuing
      • Advanced Messaging and Queues
      • Replacing Queue Subscriptions
      • Handling Unprocessed Messages
      • Advanced Queue Configuration
      • Queue Subscriptions Compared to Bookmark Replays
    • Message Types
      • Default Message Types
      • BFlat Messages
      • MessagePack Messages
      • Composite Messages
      • Protobuf Message Types
      • Struct Message Types
    • Command Acknowledgment
      • Requesting Acknowledgments
      • Receiving Acknowledgments
      • Bookmark Subscriptions and Completed Acknowledgments
      • Bookmark Subscriptions and Persisted Acknowledgments
      • Acknowledgment Conflation and Publish Acknowledgements
    • Transports
      • Client Connections
      • Replication Connections
      • Transport Filters
    • Running AMPS as a Linux Service
      • Installing the Service
      • Configuring the Service
      • Managing the Service
      • Uninstalling the Service
    • Logging
      • Configuring Logging
      • Log Message Format
      • Message Levels
      • Message Categories
      • Logging to a File
      • Logging to a Compressed File
      • Logging to Syslog
      • Logging to the Console
      • Looking up Errors with ampserr
    • Event Topics
      • Client Status Events
      • SOW Statistics Events
      • Persisting Event Topics
    • Utilities
      • Command-Line Basic Client
      • Dump clients.ack File
      • Dump journal File
      • Dump queues.ack File
      • Dump SOW File
      • Dump Journal Topic Index File
      • Find Bookmark or Transaction ID in Transaction Log
      • Find Information in Error Log or Transaction Log
      • Identify Type of AMPS File
      • List/Explain Error Codes
      • Query Statistics Database
      • Statistics Database Report
      • Storage Performance Testing
      • Submit Minidump to 60East
      • Obsolete Utility: Upgrade File Formats
    • Monitoring AMPS
      • Statistics Collection
        • Time Range Selection
        • Output Formatting
      • Galvanometer
      • Configuring Monitoring
    • Automating AMPS with Actions
    • Replicating Messages Between Instances
      • Replication Basics
      • Configuring Replication
      • Replication Configuration Validation
      • Replication Resynchronization
      • Replication Compression
      • Destination Server Failover
      • Two-Way Replication
      • PassThrough Replication
      • Guarantees on Ordering
      • Replication Security
      • Understanding Replication Message Routing
      • Replicated Queues
      • Replication Best Practices
    • Highly Available AMPS Installations
      • Overview of High Availability
        • Example: Pair of Instances for Failover
        • Example: Regional Distribution
        • Example: Regional Distribution with HA
        • Example: Hub and Spoke / Expandable Mesh
      • Details of High Availability
      • Slow Client Management and Capacity Limits
      • Message Ordering Considerations
    • Operation and Deployment
      • Capacity Planning
      • Linux OS Settings
      • Upgrading AMPS
      • Using AMPS with a Proxy
      • Operations Best Practices
    • Securing AMPS
      • Authentication
      • Entitlement
      • Providing an Identity for Outbound Connections
      • Protecting Data in Transit Using TLS/SSL
    • Troubleshooting AMPS
      • Planning for Troubleshooting
      • Diagnostic Utilities
      • Finding Information in the Log
      • Reading Replication Log Messages
      • Troubleshooting Disconnected Clients
      • Troubleshooting Regular Expression Subscriptions
    • AMPS Distribution Layout
    • Optionally-Loaded Modules
      • Optional Functions
        • Legacy Messaging Functions
        • Special-Purpose Functions
      • Optional SOW Key Generator
        • Chaining Key Generator
      • Optional Authentication/Entitlements Modules
        • RESTful Authentication and Entitlements
        • Multimethod Authentication Module
        • Simple Access Entitlements Module
      • Optional Authenticator Modules
        • Multimethod Authenticator
        • Command Execution Authenticator
    • AMPS Statistics
    • File Format Versions
  • AMPS Configuration Guide
    • AMPS Configuration Basics
      • Getting Started With AMPS Configuration
      • Units, Intervals, and Environment Variables
      • Working With Configuration Files
      • Including External Files
    • Instance Level Configuration
    • Admin Server and Statistics
    • Modules
    • Message Types
    • Transports
    • Logging
    • State of the World (SOW)
      • SOW/Topic
      • SOW/*Queue
      • SOW/ConflatedTopic
      • SOW/View
    • Replication
      • Replication Validation
    • Transaction Log
    • Authentication
    • Entitlement
    • Actions
      • Configuration for Actions
      • Choosing When an Action Runs
        • On a Schedule
        • On AMPS Startup or Shutdown
        • On a Linux Signal
        • On a REST Request
        • On Minidump Creation
        • On Client Connect or Disconnect
        • On Client Logon
        • On Client Offline Message Buffering
        • On Subscribe or Unsubscribe
        • On Incoming Replication Connections
        • On Outgoing Replication Connections
        • On Message Published to AMPS
        • On Message Delivered to Subscriber
        • On Message Affinity
        • On SOW Message Expiration
        • On SOW Message Delete
        • On OOF Message
        • On Message Condition Timeout
        • On Message State Change
        • On a Custom Event
      • Choosing What an Action Does
        • Rotate Error/Event Log
        • Compress Files
        • Truncate Statistics
        • Manage Transaction Log Journal Files
        • Remove Files
        • Delete SOW Messages
        • Compact SOW Topic
        • Query SOW Topic
        • Manage Security
        • Enable or Disable Transports
        • Publish Message
        • Manage Replication Acknowledgment
        • Extract Values from a Message
        • Translate Data Within an Action
        • Increment Counter
        • Raise a Custom Event
        • Execute System Command
        • Manage Queue Transfers
        • Create Minidump
        • Shut Down AMPS
        • Debug Action Configuration
      • Conditionally Stopping an Action
        • Based on File System Capacity
        • Based on an Expression
      • Examples of Action Configuration
        • Archive Journals Once a Week
        • Archive Journals On RESTful Command
        • Record Expired Queue Messages to a Dead Letter Topic
        • Copy Messages that Exceed a Timeout to a Different Topic
        • Deactivate and Reactivate Security on Signals
        • Reset Entitlements for a Disconnected Client
        • Extract Values from a Published Message
        • Shut Down AMPS When a Filesystem Is Full
        • Increment a Counter and Echo a Message
    • Protocols
  • AMPS Monitoring Guide
    • Statistics Types
    • Table Reference
    • Administrative Actions
    • Host Statistics
      • cpu
      • disks
      • memory
      • name
      • network
    • AMPS Instance Statistics
      • api
      • clients
      • config.xml
      • config_path
      • conflated_topics
      • cpu
      • cwd
      • description
      • environment
      • lifetimes
      • logging
      • memory
      • message_types
      • name
      • name_hash
      • pid
      • processors
      • queues
      • queries
      • replication
      • sow
      • statistics
      • subscriptions
      • timestamp
      • transaction_log
      • transports
      • tuning
      • uptime
      • user_id
      • version
      • views
  • AMPS Command Reference
    • Commands to AMPS
      • logon
      • Publishing
        • publish
        • delta_publish
      • Subscribing to and Querying Topics
        • subscribe
        • sow
        • sow_and_subscribe
        • unsubscribe
        • delta_subscribe
        • sow_and_delta_subscribe
      • Removing Messages (SOW/Topic or Message Queue)
      • heartbeat
      • flush
    • Responses from AMPS
      • sow: Content from Server
      • publish: Content from Server
      • oof: Content from Server
      • ack: Status from Server
      • group_begin / group_end : Result Set Delimiters
    • Protocol Reference
      • AMPS Protocol
      • Legacy Protocols Reference
    • Command Cookbook
      • Cookbook: Delta Publish
      • Cookbook: Delta Subscribe
      • Cookbook: Publish
      • Cookbook: SOW
      • Cookbook: SOW and Delta Subscribe
      • Cookbook: SOW and Subscribe
      • Cookbook: SOW Delete
      • Cookbook: Subscribe
  • Deployment Checklist
    • Ensure Sufficient Capacity
    • Apply System and AMPS Configuration
    • Create Maintenance Plan
    • Create Monitoring Strategy
    • Create Patch and Upgrade Plan
    • Create and Test Support Process
    • Conclusion
  • AMPS Clients
    • Performance Tips and Best Practices
    • C++
    • C#/.NET
    • Java
    • JavaScript
    • Python
Powered by GitBook

Get Help

  • FAQ
  • Legacy Documentation
  • Support / Contact Us

Get AMPS

  • Evaluate
  • Develop

60East Resources

  • Website
  • Privacy Policy

Copyright 2013-2024 60East Technologies, Inc.

On this page
  • Configuring AMPS to Persist Statistics
  • Introduction to SQLite3
  • Starting SQLite3
  • Simple SQLite3 Commands
  • Statistics Table Design
  • Table Naming Scheme
  • Example Queries
  • Using the amps-sqlite3 Utility
  • SQLite Tips and Troubleshooting
  • Converting AMPS Statistics Time to an ISO8601 Datetime
  • Shrinking an AMPS Statistics Database
  • Troubleshooting "Database Disk Image is Malformed"
Export as PDF
  1. AMPS User Guide

AMPS Statistics

AMPS provides the ability to record the statistics gathered from the AMPS instance and the host machine.

The AMPS statistics database is stored in sqlite3 format and can be used with any of the standard sqlite3 tools. This section assumes that you are using the standard sqlite3 package installed on your local computer. While you may be able to run the SQL examples in this guide using other packages, this guide will assume that all SQL commands will be executed with sqlite3.

Notice that the statistics subsystem is independent of the other subsystems in AMPS, and is the only part of AMPS that uses the sqlite3 format. You cannot use sqlite3 tools with SOW files, journal files or .ack files: these files use formats specifically designed for high performance messaging.

Working with the AMPS statistics database is described in more detail in the following sections.

Configuring AMPS to Persist Statistics

By default, AMPS maintains statistics in memory. To configure AMPS to record the statistics to a file, the following configuration options are available in the AMPS configuration file to update the location and frequency of the statistics database file.

<AMPSConfig>

    ...

    <Admin>
        <InetAddr>localhost:9090</InetAddr>
        <FileName>./stats.db</FileName>
        <Interval>5s</Interval>
    </Admin>

    ...

</AMPSConfig>

In the example above, the AMPS administration interface is set to collect statistics every 5 seconds as indicated by the <Interval> tag. The AMPS administration interface is additionally configured to save the statistics in the stats.db file, which will be created in the directory where AMPS was started.

AMPS does not require that statistics are persisted. Persisting statistics enables information about instance performance, capacity, usage, and so on to be analyzed offline (rather than by using RESTful operations against a running instance). This also enables statistical information about the instance to be persisted when AMPS restarts.

Introduction to SQLite3

Starting SQLite3

To start sqlite3 with the stats.db file simply type:

$> sqlite3 ./stats.db

This will create a command prompt that looks like the following:

$> sqlite3 ./stats.db
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

To exit the sqlite3 prompt at any time, use the Ctrl+d sequence.

Simple SQLite3 Commands

Tables

To get a listing of all available tables in the sqlite database type the .table command.

sqlite> .table
HCPUS_DYNAMIC                   IMEMORY_CACHES_DYNAMIC
HCPUS_STATIC                    IMEMORY_CACHES_STATIC
HDISKS_DYNAMIC                  IMEMORY_DYNAMIC
HDISKS_STATIC                   IMEMORY_STATIC
HMEMORY_DYNAMIC                 IPROCESSORS_DYNAMIC
HMEMORY_STATIC                  IPROCESSORS_STATIC
HNET_DYNAMIC                    IQUEUES_DYNAMIC
HNET_STATIC                     IQUEUES_STATIC
ICLIENTS_DYNAMIC                IREPLICATIONS_DYNAMIC
ICLIENTS_STATIC                 IREPLICATIONS_STATIC
ICONFLATEDTOPICS_DYNAMIC        ISOW_DYNAMIC
ICONFLATEDTOPICS_STATIC         ISOW_STATIC
ICONSOLE_LOGGERS_DYNAMIC        ISTATISTICS_DYNAMIC
ICONSOLE_LOGGERS_STATIC         ISTATISTICS_STATIC
ICPUS_DYNAMIC                   ISUBSCRIPTIONS_DYNAMIC
ICPUS_STATIC                    ISUBSCRIPTIONS_STATIC
IFILE_LOGGERS_DYNAMIC           ISYSLOG_LOGGERS_DYNAMIC
IFILE_LOGGERS_STATIC            ISYSLOG_LOGGERS_STATIC
IGLOBALS_DYNAMIC                ITRANSPORTS_DYNAMIC
IGLOBALS_STATIC                 ITRANSPORTS_STATIC
ILIFETIMES_DYNAMIC              IVIEWS_DYNAMIC
ILIFETIMES_STATIC               IVIEWS_STATIC

Schema

To view the schema for any table, type the .schema <table name> command where <table name> is the name of the table to inspect.

sqlite> .schema IFILE_LOGGERS_DYNAMIC

CREATE TABLE IFILE_LOGGERS_DYNAMIC( timestamp integer,
static_id integer, bytes_written integer, PRIMARY
KEY( timestamp, static_id ) );

Statistics Table Design

This section describes the philosophy of how the AMPS tables are designed within the statistics database. This chapter also includes some examples of some useful queries which can give an administrator more information than just the raw data would normally give them. Such information can be a powerful tool in diagnosing perceived problems in AMPS.

Table Naming Scheme

Tables in the database use the following naming scheme:

<I|H><STAT>_<STATIC|DYNAMIC>

Where:
I = AMPS instance statistics
H = Host statistics
STAT = The statistics that are collected (MEMORY, CPUs,
SUBSCRIPTIONS, etc)
STATIC = Attributes that rarely change for an object
(such as client name, CPU #)
DYNAMIC = Stats that are expected to change on every
sample (rates, counters, and so on)

Example Queries

To view which clients have fallen behind at one time, run:

sqlite> SELECT s.client_name, MAX(d.queue_max_latency),
MAX(queued_bytes_out) FROM ICLIENTS_DYNAMIC d
JOIN ICLIENTS_STATIC s ON (s.static_id=d.static_id)
GROUP BY s.client_name;

To view clients that are behind in the latest sample:

sqlite> SELECT s.client_name, d.queue_max_latency,
queued_bytes_out FROM ICLIENTS_DYNAMIC d
JOIN ICLIENTS_STATIC s ON (s.static_id=d.static_id)
WHERE d.timestamp = (SELECT MAX(d.timestamp)
FROM ICLIENTS_DYNAMIC d) AND d.queue_max_latency > 0;

Using the amps-sqlite3 Utility

The AMPS distribution includes a convenience utility, amps-sqlite3, for easily running queries against a statistics database.

The utility takes two parameters, as shown below:

Parameter

Description

The sqlite3 database file to query.

The query to run. Notice that the query must be enclosed in quotes, since this is a command-line program run by the Linux shell.

The amps-sqlite3 utility joins the STATIC and DYNAMIC tables together, making a single table that is easier to query on. For example, the script joins the ICLIENTS_DYNAMIC and ICLIENTS_STATIC tables together into a single ICLIENTS table.

The amps-sqlite3 utility also provides a set of convenience functions that can be included in the query.

Option

Description

ISO8601(timestamp)

Convert timestamp to an ISO8601 format string.

ISO8601_local(timestamp)

Convert timestamp to an ISO8601 format string in the local timezone.

timestamp(string)

Convert the provided ISO8601 format string to a timestamp.

To use amps-sqlite3, simply provide the file name of the database to query and the query to run. For example, the following query returns the set of samples AMPS has recorded for the system_percent consumed on each CPU while the instance has been running:

$ amps-sqlite3 stats.db "select iso8601(timestamp),system_percent from hcpus order by timestamp"

SQLite Tips and Troubleshooting

This section includes information on SQLite tasks that may not be immediately obvious and troubleshooting information on SQLite.

Converting AMPS Statistics Time to an ISO8601 Datetime

This Python function shows how to convert an AMPS timestamp to an ISO8601 datetime. You can use the equivalent in your language of choice to convert between the timestamps recorded in the statistics database and ISO8601 timestamps.

def iso8601_time(amps_time):
    """
    Converts AMPS stats time into an ISO8601 datetime.
    """
    pt = float(amps_time)/1000 - 210866803200 # subtract the Unix epoch
    it = int(pt)
    ft = pt-it
    return time.strftime("%Y%m%dT%H%M%S", time.localtime(it)) + ("%.6f" % ft)[1:]

Shrinking an AMPS Statistics Database

If the retention policy for an AMPS statistics database has changed such that there is unused space in the file at the maximum retention size, it may be helpful to shrink the size of the statistics database.

Running this procedure will only reduce the size of the database if the database has been truncated.

To do this:

  1. Take the AMPS instance offline.

  2. (Optional, but recommended) Make a backup copy of the AMPS statistics database on another device.

  3. Run the sqlite VACUUM command to shrink the database:

    sqlite3 stats.db 'VACUUM'

    This operation may require free disk space equal to the current size of the statistics database. If the operation fails, the vacuum rolls back without changing the database.

A database should not be vacuumed while AMPS is running.

Troubleshooting "Database Disk Image is Malformed"

To repair this error, you need to extract the data from the SQLite datastore and create a new datastore. To do this:

  1. Open the sqlite datastore. For example, if the database store is named stats.db, the command would be:

sqlite3 stats.db
  1. Dump the data into a SQL script.

.mode insert
.output stats_data.sql
.dump
.exit

This creates a series of SQL commands that recreate the data in the database.

  1. Make sure that the script commits updates (depending on the version of sqlite3 and the state of the database, the script may roll back the updates rather than committing them without this step).

sed -i 's/^ROLLBACK;/COMMIT;/ig' stats_data.sql
  1. Now create a new database file using the SQL commands.

sqlite3 good.db < stats_data.sql

Finally, adjust the configuration of the Admin server to use the new database (in this example, good.db) or copy the new database over the old database.

PreviousCommand Execution AuthenticatorNextFile Format Versions

Last updated 2 months ago

This section is a quick reference to sqlite3. It is intended to help in getting started with examining the statistics provided by AMPS. While this guide will be sufficient to execute the examples listed, a more comprehensive guide of the sqlite3 command line tool is available at .

 database 
 query 
http://www.sqlite.org/sqlite.html