2023-11-07 10:03:57 +00:00
# include <Interpreters/BlobStorageLog.h>
2024-04-09 16:49:46 +00:00
# include <base/getFQDNOrHostName.h>
2023-11-07 10:03:57 +00:00
# include <DataTypes/DataTypesNumber.h>
# include <DataTypes/DataTypeString.h>
# include <DataTypes/DataTypeEnum.h>
# include <DataTypes/DataTypeDateTime.h>
# include <DataTypes/DataTypeDateTime64.h>
# include <DataTypes/DataTypeLowCardinality.h>
# include <DataTypes/DataTypeDate.h>
namespace DB
{
2024-01-12 15:39:22 +00:00
ColumnsDescription BlobStorageLogElement : : getColumnsDescription ( )
2023-11-07 10:03:57 +00:00
{
auto event_enum_type = std : : make_shared < DataTypeEnum8 > (
DataTypeEnum8 : : Values {
{ " Upload " , static_cast < Int8 > ( EventType : : Upload ) } ,
{ " Delete " , static_cast < Int8 > ( EventType : : Delete ) } ,
{ " MultiPartUploadCreate " , static_cast < Int8 > ( EventType : : MultiPartUploadCreate ) } ,
{ " MultiPartUploadWrite " , static_cast < Int8 > ( EventType : : MultiPartUploadWrite ) } ,
{ " MultiPartUploadComplete " , static_cast < Int8 > ( EventType : : MultiPartUploadComplete ) } ,
{ " MultiPartUploadAbort " , static_cast < Int8 > ( EventType : : MultiPartUploadAbort ) } ,
} ) ;
2024-01-12 15:39:22 +00:00
return ColumnsDescription
{
2024-04-09 16:49:46 +00:00
{ " hostname " , std : : make_shared < DataTypeLowCardinality > ( std : : make_shared < DataTypeString > ( ) ) , " Hostname of the server executing the query. " } ,
2024-03-08 17:05:56 +00:00
{ " event_date " , std : : make_shared < DataTypeDate > ( ) , " Date of the event. " } ,
{ " event_time " , std : : make_shared < DataTypeDateTime > ( ) , " Time of the event. " } ,
{ " event_time_microseconds " , std : : make_shared < DataTypeDateTime64 > ( 6 ) , " Time of the event with microseconds precision. " } ,
2023-11-07 10:03:57 +00:00
2024-03-08 17:05:56 +00:00
{ " event_type " , event_enum_type , " Type of the event. Possible values: 'Upload', 'Delete', 'MultiPartUploadCreate', 'MultiPartUploadWrite', 'MultiPartUploadComplete', 'MultiPartUploadAbort' " } ,
2023-11-07 10:03:57 +00:00
2024-03-08 17:05:56 +00:00
{ " query_id " , std : : make_shared < DataTypeString > ( ) , " Identifier of the query associated with the event, if any. " } ,
{ " thread_id " , std : : make_shared < DataTypeUInt64 > ( ) , " Identifier of the thread performing the operation. " } ,
{ " thread_name " , std : : make_shared < DataTypeString > ( ) , " Name of the thread performing the operation. " } ,
2023-11-07 10:03:57 +00:00
2024-03-08 17:05:56 +00:00
{ " disk_name " , std : : make_shared < DataTypeLowCardinality > ( std : : make_shared < DataTypeString > ( ) ) , " Name of the associated disk. " } ,
{ " bucket " , std : : make_shared < DataTypeString > ( ) , " Name of the bucket. " } ,
{ " remote_path " , std : : make_shared < DataTypeString > ( ) , " Path to the remote resource. " } ,
{ " local_path " , std : : make_shared < DataTypeString > ( ) , " Path to the metadata file on the local system, which references the remote resource. " } ,
{ " data_size " , std : : make_shared < DataTypeUInt64 > ( ) , " Size of the data involved in the upload event. " } ,
2023-11-07 10:03:57 +00:00
2024-03-08 17:05:56 +00:00
{ " error " , std : : make_shared < DataTypeString > ( ) , " Error message associated with the event, if any. " } ,
2023-11-07 10:03:57 +00:00
} ;
}
void BlobStorageLogElement : : appendToBlock ( MutableColumns & columns ) const
{
size_t i = 0 ;
auto event_time_seconds = timeInSeconds ( event_time ) ;
2024-04-09 16:49:46 +00:00
columns [ i + + ] - > insert ( getFQDNOrHostName ( ) ) ;
2023-11-07 10:03:57 +00:00
columns [ i + + ] - > insert ( DateLUT : : instance ( ) . toDayNum ( event_time_seconds ) . toUnderType ( ) ) ;
columns [ i + + ] - > insert ( event_time_seconds ) ;
columns [ i + + ] - > insert ( Decimal64 ( timeInMicroseconds ( event_time ) ) ) ;
columns [ i + + ] - > insert ( static_cast < Int8 > ( event_type ) ) ;
columns [ i + + ] - > insert ( query_id ) ;
columns [ i + + ] - > insert ( thread_id ) ;
columns [ i + + ] - > insert ( thread_name ) ;
columns [ i + + ] - > insert ( disk_name ) ;
columns [ i + + ] - > insert ( bucket ) ;
columns [ i + + ] - > insert ( remote_path ) ;
columns [ i + + ] - > insert ( local_path ) ;
columns [ i + + ] - > insert ( data_size ) ;
columns [ i + + ] - > insert ( error_message ) ;
}
}