Reporting¶

[edit on GitHub]

Notation

This documentation is meant to support existing Chef customers using Reporting.

Are y'all a new Chef customer, or looking to gain better insight into your armada? Take reward of Chef Automate. You'll get a graphical interface and query language that gives y'all insight into operational, compliance, and workflow events. Yous can endeavor out Chef Automate here.

Use Reporting to go on rail of what happens during the execution of chef-client runs across all of the machines that are under direction by Chef. Reports can be generated for the entire system and they can be generated for specific nodes.

Reporting data is collected during the chef-client run and the results are posted to the Chef server at the terminate of the chef-client run at the same time the node object is uploaded to the Chef server.

Requirements¶

Reporting has the following minimum requirements:

  • Chef server 12
  • chef-client version eleven.6.0 (or subsequently)

Reporting can make use of an external database, but to do so Reporting 1.v.five or later is needed along with Chef server 12.two.0 or later.

The Reporting customer is built into the chef-client and can run on all platforms that chef-client is supported on.

Warning

Reporting does not work on chef-client version 11.8.0; upgrade to chef-customer version 11.8.ii (or later) if Reporting is existence run in your organization.

Alert

The only supported versions of Reporting are 1.five.5 or subsequently.

Reporting is configured as a premium feature of the Chef server and requires credence of the Chef MLSA as function of the installation process, starting with version one.6.0.

The Reporting Run¶

A "chef-client run" is the term used to depict a series of steps that are taken by the chef-customer when it is configuring a node. Reporting, when configured, is likewise tracked during the chef-client run. The following diagram shows how Reporting fits into the chef-client run, and then the list below the diagram describes in greater detail each of those stages.

_images/reporting_run.png

When reports are generated equally part of a chef-client run, in improver to what normally occurs during the chef-customer run, the following happens:

Stages Clarification
Generate reporting ID At the beginning of the chef-customer run, the chef-client pings Reporting to notify it that a chef-client run is starting and to generate a unique identifier for the chef-client run and so that it can be associated with the reporting data.
Send the reporting data to the Chef server At the end of the chef-client run, the chef-client pings Reporting, and then sends the data that was collected during the chef-client run to the Chef server so that it can be added to the Reporting database.

Chef Manage, Reports¶

The Chef management console enables the management of nodes, data numberless, roles, environments, and cookbooks by using a web user interface. In addition, access to nodes, data bags, roles, environments, and cookbooks is configurable using part-based access command (RBAC).

When Reporting and Chef management panel are both added to the Chef server, a user interface for Reporting is as well available.

_images/step_manage_webui_reports.png

Knife Reporting¶

The knife reporting subcommand is used by Reporting to report virtually chef-client runs beyond the organization.

Notation

Review the listing of common options available to this (and all) knife subcommands and plugins.

Install the Plugin¶

To install the pocketknife reporting plugin using RubyGems, run the following command:

                $ /opt/chef/embedded/bin/gem install knife-reporting              

where /opt/chef/embedded/bin/ is the path to the location where the chef-client expects pocketknife plugins to be located. If the chef-customer was installed using RubyGems, omit the path in the previous example.

runs list¶

Apply the runs list argument to return a list of chef-client runs by system or by node.

Syntax¶

This argument has the following syntax:

                  $ knife runs list NODE_NAME                

Options¶

This argument has the following options:

-e MM-DD-YYYY , --endtime MM-DD-YYYY
Find runs with an terminate time less than or equal to the specified engagement. This choice must be used in conjunction with --starttime and may define up to a 90-day fourth dimension menstruation.
RUN_ID
Required. The identifier for a chef-customer run.
-r N , --rows Due north
The number of rows to be returned.
-south MM-DD-YYYY , --starttime MM-DD-YYYY
Detect runs with a start time greater than or equal to the specified date. This option must be used in conjunction with --endtime and may define upwards to a 90-solar day time period.
-u , --unixtimestamps
Show get-go and end times as UNIX timestamps. This option may exist used when the --endtime and --starttime options are used.

Examples¶

View all chef-customer runs for an organization

To return a list of chef-client runs by organization (i.e. "every chef-client run that took identify beyond every single node in the system"), run the following command:

View all chef-customer runs for a unmarried node

To render a list of chef-customer runs that occurred for a node, run the following command:

                  $ knife runs list node_name                

where node_name is the proper name of a node.

View a specific chef-client run

To return a list of chef-client runs that occurred for a specific node, run the following command:

                  $ pocketknife runs list node_name                  30077269-59d0-4283-81f6-8d23cbed3a7a                

where node_name is the name of a node.

runs show¶

Use the runs bear witness statement to render the details for a chef-client run (by run identifier).

Syntax¶

This argument has the following syntax:

Options¶

This argument has the following options:

RUN_ID
The identifier for a chef-client run.

Examples¶

Show runs by run identifier

To return details nearly a specific chef-client run, run the following control:

                  $ knife runs bear witness c40csdcf2-5007-433c-95570-8e0c7e55f496                

For a chef-customer run that succeeded, the command will return something like to:

                  $ run_detail:     data:       end_time:                  2013-12-10T17:18:49Z       node_name:         kitchen-vagrant       run_id:            c40csdcf2-5007-433c-95570-8e0c7e55f496       run_list:                  [                  "recipe[createfile]"                  ]                  start_time:                  2013-12-10T17:eighteen:49Z       status:            success       total_res_count:                  1                  updated_res_count:                  1                  run_resources:     cookbook_name:    createfile     cookbook_version:                  0.0.0     duration:                  41                  final_state:       checksum: f29bc64a9d3123454gfdsffdb3285f5bsdfsdf72414671e0ca3b2e0de       group:    root       style:                  0755                  owner:    root     id:               /tmp/test     initial_state:       checksum:       group:       manner:       owner:     proper name:             /tmp/test     result:           bear upon     blazon:             file     uri:              URI                

For a chef-client run that failed (or had some type of mistake), the command will return something similar to:

                  $ run_detail:     data:       exception:         backtrace:                  [                  "/opt/chef/embedded/lib/ruby-red/1.9.3/net/http.rb:763:in 'initialize'",                  "/opt/chef/embedded/lib/crimson/one.9.3/internet/http.rb:763:in 'open'",                  "/opt/chef/embedded/lib/ruby/i.nine.three/net/http.rb:763:in 'cake in connect'",                  "/opt/chef/embedded/lib/reddish/i.nine.3/timeout.rb:55:in 'timeout'",                  "/opt/chef/embedded/lib/red/1.9.3/timeout.rb:100:in 'timeout'",                  "/opt/chef/embedded/lib/blood-red/1.nine.3/net/http.rb:763:in 'connect'",                  "/opt/chef/embedded/lib/reddish/1.9.3/internet/http.rb:756:in 'do_start'",                     ...                  "/usr/bin/chef-client:23:in 'load'",                  "/usr/bin/chef-client:23:in '<main>'"                  ]                  grade:                  #<SocketError: Error connecting to URL - getaddrinfo: Temporary failure in name resolution>                  description:           sections:             Networking Error:: Error connecting to URL - getaddrinfo: Temporary failure in name resolution                                Your chef_server_url may be misconfigured, or the network could be down.             Relevant Config Settings:: chef_server_url                  "URL"                  title:    Mistake Syncing Cookbooks:           message:     Mistake connecting to URL - getaddrinfo: Temporary failure in name resolution           end_time:                  2013-12-10T14:38:18Z           node_name:         node_name           run_id:            c40csdcf2-5007-433c-95570-8e0c7e55f496           run_list:                  [                  "recipe[createfile]"                  ]                  start_time:                  2013-12-10T14:37:37Z           status:            failure           total_res_count:                  0                  updated_res_count:                  0                  run_resources:                

state_attrs Method¶

The state_attrs method is used to define the properties that volition exist tracked past the Reporting server. In general, this should be a listing of backdrop that describe the desired state of the system, such as file permissions, cloud provider data (like snapshots, volumes, identifiers, sizes, and access keys), and and so on.

The syntax for the state_attrs method is as follows:

                            state_attrs              :property              ,              :property              ,              :property            

where :property is a comma-delimited list of backdrop. For case, the ebs_volume resource (available from the aws cookbook) uses the state_attrs method to tell the Reporting server to track the following properties:

                            state_attrs              :availability_zone              ,              :aws_access_key              ,              :description              ,              :device              ,              :most_recent_snapshot              ,              :piops              ,              :size              ,              :snapshot_id              ,              :snapshots_to_keep              ,              :timeout              ,              :volume_id              ,              :volume_type            

Configuration Settings¶

Reporting relies on two settings in the client.rb file:

Setting Description
enable_reporting

Crusade the chef-client to send data to the Chef server for employ with Reporting. For example:

                                            enable_reporting                      true                    
enable_reporting_url_fatals

Cause the chef-customer run to fail when Reporting data cannot be sent to the Chef server (for any reason). For instance:

                                            enable_reporting_url_fatals                      imitation                    

Reporting API¶

The Reporting API is a Residuum API that provides access to Reporting data that is collected during a chef-client run. Reporting data is collected merely for nodes that take permission to publish Reporting data to the Chef server and only for organizations that take Reporting enabled.

Requirements¶

The Chef server API has the following requirements:

  • Access to a Chef server running version 0.10.10 or above.
  • The Accept header must be set up to application/json .
  • For PUT and POST requests, the Content-Type header must be set to application/json .
  • The X-Chef-Version header must be gear up to the version of the Chef server API that is being used.
  • A request must be signed using Mixlib::Authentication .
  • A request must be well-formatted. The easiest way to ensure a well-formatted request is to use the Chef::Residue library.

Global Endpoints¶

A global endpoint may be used to access all of the organizations on the Chef server.

/reports/status¶

The /reports/status endpoint has the post-obit methods: Go .

Go¶

The Become method is used to return the status of the system components used by Reporting.

This method does not have any parameters.

Asking

Response

The response is similar to:

                                        {                    "rest_api"                    :                    "online"                    ,                    "sql_db"                    :                    "online"                    ,                    "index"                    :                    "online"                    }                  

where index is the Chef server search index. If the organisation component is non online, the response will return offline .

Response Codes

Response Lawmaking Description
200 OK. The asking was successful.
404 Not institute. The requested object does not exist.
406 Invalid request. The protocol version is wrong.

Organization Endpoints¶

Each arrangement-specific hallmark asking must include /organizations/ORG_NAME equally part of the name for the endpoint. For case, the full endpoint for getting the details for a specific reporting run identifier for a node:

                Get /organizations/ORG_NAME/reports/nodes/NODE/runs/RUNID              

where ORG_NAME is the name of the system, NODE is the name of the node, and RUNID is the reporting run identifier.

/reports/nodes/NODE/runs¶

The /reports/nodes/NODE/runs endpoint has the following methods: GET and POST .

GET¶

The GET method is used to return Reporting data for a chef-client run.

This method has no parameters.

Request

                    GET /organizations/ORG/reports/nodes/NODE/runs                  

Response

The response is similar to:

                                        {                    "node_name"                    :                    "pkd01234567"                    ,                    "run_id"                    :                    "550e4500-e22b-4ad4-a716-446659876500"                    ,                    "start_time"                    :                    "2014-11-14T23:33:34Z"                    "status"                    :                    "started"                    }                  

Response Codes

Response Code Clarification
200 OK. The request was successful.
404 Not found. The requested object does not exist.
406 Invalid request. The protocol version is wrong.

/reports/nodes/NODE/runs/RUNID/RESID¶

The /reports/nodes/NODE/runs/RUNID/RESID endpoint has the following methods: GET .

Go¶

The GET method is used to render a list of what changed during the chef-client run for the specified resource.

This method has no parameters.

Request

                    Go /organizations/ORG/reports/nodes/NODE/runs/RUNID/RESID                  

Response

The response is like to:

                    {   resource_detail :   {     "content_delta" : string   } }                  

Response Codes

Response Code Description
200 OK. The request was successful.
404 Not found. The requested object does non exist.
406 Invalid request. The protocol version is wrong.

/reports/nodes/NODE/runs/RUNID¶

The /reports/nodes/NODE/runs/RUNID endpoint has the following methods: Become and POST .

GET¶

The Go method is used to return a list of resources for a given Reporting run identifier.

This method has the post-obit parameters:

Parameter Clarification
detail Optional. When true , include the run_detail JSON object in the output. Default value: faux .
rows Optional. The number of resources to render. Default value: ten .
start Optional. The row at which the results volition start. Default value: 0 .

Request

                    Get /organizations/ORG/reports/nodes/NODE/runs/RUNID                  

Response

The response is similar to:

                                        {                    run_resources                    :                    [                    {                    "uri"                    :                    uri                    ,                    "cookbook_name"                    :                    string                    ,                    "cookbook_version"                    :                    string                    ,                    "elapsing"                    :                    numeric                    cord                    -                    milliseconds                    ,                    "id"                    :                    string                    ,                    "type"                    :                    string                    ,                    "name"                    :                    string                    ,                    "issue"                    :                    string                    ,                    "initial_state"                    :                    json                    -                    object                    ,                    "final_state"                    :                    json                    -                    object                    ,                    }                    ],                    run_detail                    :                    {                    "node_name"                    :                    string                    ,                    "updated_res_count"                    :                    integer                    ,                    "total_res_count"                    :                    integer                    ,                    "run_list"                    :                    cord                    ???                    TODO                    :                    Verify                    this                    is                    correct                    "start_time"                    :                    timestamp                    "end_time"                    :                    timestamp                    "data"                    :                    {                    0..i                    exception                    -                    record                    },                    "status"                    }                    }                  

Response Codes

Response Lawmaking Description
200 OK. The request was successful.
404 Not institute. The requested object does not be.
406 Invalid request. The protocol version is incorrect.

/reports/org/runs¶

The /reports/org/runs endpoint has the following methods: GET .

Go¶

The Go method is used to return data well-nigh chef-client runs for all nodes in the specified organization.

This method has the following parameters:

Parameter Description
from Optional. Use to specify the time before which node data will not be returned. Use with until to define a range.
rows Optional. The number of resource to return. Default value: 10 .
start Optional. The row at which the results will start. Default value: 0 .
status Optional. Utilize to specify a status lawmaking. When a status lawmaking is provided, but nodes with that status volition be returned. When a status code is non provided, all nodes volition be returned. Possible values: aborted , failure , or success .
until Optional. Use to specify the fourth dimension afterward which node information will not be returned. Use with until to define a range.

Request

                    GET /organizations/ORG/reports/org/runs                  

Response

The response is like to:

Response Codes

Response Code Description
200 OK. The asking was successful.
404 Non plant. The requested object does not exist.
406 Invalid request. The protocol version is incorrect.

/reports/runs/counts¶

The /reports/runs/counts endpoint has the following methods: Get .

Get¶

The GET method is used to return the frequency of chef-client runs, per-minute, per-60 minutes, per-day, or per-week.

This method has the following parameters:

Parameter Description
granularity Required. The length of fourth dimension for which chef-client run counts are returned. Possible values: hour , minute , twenty-four hours , or week .

Asking

                    GET /organizations/ORG/reports/runs/counts                  

Response

The response is like to:

Response Codes

Response Code Clarification
200 OK. The request was successful.
404 Non plant. The requested object does not exist.
406 Invalid request. The protocol version is incorrect.

/reports/runs/durations¶

The /reports/runs/durations endpoint has the following methods: GET .

Get¶

The GET method is used to return the frequency of chef-client runs that occurred within a specified range.

This method has the following parameters:

Parameter Clarification
from Optional. Use to specify the time before which node information will not exist returned. Use with until to define a range.
until Optional. Use to specify the time after which node data will not be returned. Utilize with until to define a range.

Asking

                    GET /organizations/ORG/reports/runs/durations                  

Response

The response is similar to:

Response Codes

Response Code Description
200 OK. The request was successful.
404 Not establish. The requested object does not exist.
406 Invalid request. The protocol version is incorrect.